Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
bridge.h File Reference

Bridging API. More...

#include "asterisk/bridge_features.h"
#include "asterisk/bridge_channel.h"
#include "asterisk/bridge_roles.h"
#include "asterisk/dsp.h"
#include "asterisk/uuid.h"

Go to the source code of this file.

Data Structures

struct  ast_bridge
 Structure that contains information about a bridge. More...
 
struct  ast_bridge_channels_list
 
struct  ast_bridge_methods
 Bridge virtual methods table definition. More...
 
struct  ast_bridge_snapshot
 Structure that contains a snapshot of information about a bridge. More...
 
struct  ast_bridge_softmix
 
struct  ast_bridge_video_mode
 Data structure that defines a video source mode. More...
 
struct  ast_bridge_video_sfu_data
 This is used for selective forwarding unit configuration. More...
 
struct  ast_bridge_video_single_src_data
 This is used for both SINGLE_SRC mode to set what channel should be the current single video feed. More...
 
struct  ast_bridge_video_talker_src_data
 This is used for both SINGLE_SRC_TALKER mode to set what channel should be the current single video feed. More...
 
struct  transfer_channel_data
 AO2 object that wraps data for transfer_channel_cb. More...
 

Macros

#define ast_bridge_lock(bridge)   _ast_bridge_lock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
 Lock the bridge. More...
 
#define ast_bridge_lock_both(bridge1, bridge2)
 Lock two bridges.
 
#define ast_bridge_trylock(bridge)   _ast_bridge_trylock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
 Try locking the bridge. More...
 
#define ast_bridge_unlock(bridge)   _ast_bridge_unlock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
 Unlock the bridge. More...
 

Typedefs

typedef void(* ast_bridge_destructor_fn) (struct ast_bridge *self)
 Destroy the bridge. More...
 
typedef void(* ast_bridge_dissolving_fn) (struct ast_bridge *self)
 The bridge is being dissolved. More...
 
typedef int(* ast_bridge_merge_priority_fn) (struct ast_bridge *self)
 Get the merge priority of this bridge. More...
 
typedef void(* ast_bridge_notify_masquerade_fn) (struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
 Notify the bridge that this channel was just masqueraded. More...
 
typedef void(* ast_bridge_pull_channel_fn) (struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
 Pull this channel from the bridge. More...
 
typedef int(* ast_bridge_push_channel_fn) (struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
 Push this channel into the bridge. More...
 
typedef void(* transfer_channel_cb) (struct ast_channel *chan, struct transfer_channel_data *user_data, enum ast_transfer_type transfer_type)
 Callback function type called during blind transfers. More...
 

Enumerations

enum  ast_bridge_capability {
  AST_BRIDGE_CAPABILITY_HOLDING = (1 << 0), AST_BRIDGE_CAPABILITY_EARLY = (1 << 1), AST_BRIDGE_CAPABILITY_NATIVE = (1 << 2), AST_BRIDGE_CAPABILITY_1TO1MIX = (1 << 3),
  AST_BRIDGE_CAPABILITY_MULTIMIX = (1 << 4)
}
 Capabilities for a bridge technology. More...
 
enum  ast_bridge_impart_flags { AST_BRIDGE_IMPART_CHAN_MASK = (1 << 0), AST_BRIDGE_IMPART_CHAN_DEPARTABLE = (0 << 0), AST_BRIDGE_IMPART_CHAN_INDEPENDENT = (1 << 0), AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP = (1 << 1) }
 
enum  ast_bridge_join_flags { AST_BRIDGE_JOIN_PASS_REFERENCE = (1 << 0), AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP = (1 << 1) }
 
enum  ast_bridge_optimization {
  AST_BRIDGE_OPTIMIZE_SWAP_TO_CHAN_BRIDGE, AST_BRIDGE_OPTIMIZE_SWAP_TO_PEER_BRIDGE, AST_BRIDGE_OPTIMIZE_MERGE_TO_CHAN_BRIDGE, AST_BRIDGE_OPTIMIZE_MERGE_TO_PEER_BRIDGE,
  AST_BRIDGE_OPTIMIZE_PROHIBITED
}
 Tells, if optimization is allowed, how the optimization would be performed. More...
 
enum  ast_bridge_video_mode_type { AST_BRIDGE_VIDEO_MODE_NONE = 0, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, AST_BRIDGE_VIDEO_MODE_SFU }
 Video source modes. More...
 
enum  ast_bridge_video_sfu_remb_behavior {
  AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE = 0, AST_BRIDGE_VIDEO_SFU_REMB_LOWEST, AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST, AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE_ALL,
  AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL, AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL, AST_BRIDGE_VIDEO_SFU_REMB_FORCE
}
 REMB report behaviors. More...
 
enum  ast_transfer_result { AST_BRIDGE_TRANSFER_SUCCESS, AST_BRIDGE_TRANSFER_NOT_PERMITTED, AST_BRIDGE_TRANSFER_INVALID, AST_BRIDGE_TRANSFER_FAIL }
 
enum  ast_transfer_type { AST_BRIDGE_TRANSFER_SINGLE_PARTY, AST_BRIDGE_TRANSFER_MULTI_PARTY }
 

Functions

static void _ast_bridge_lock (struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
 
static int _ast_bridge_trylock (struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
 
static void _ast_bridge_unlock (struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var)
 
struct ast_bridgeast_bridge_base_new (uint32_t capabilities, unsigned int flags, const char *creator, const char *name, const char *id)
 Create a new base class bridge. More...
 
int ast_bridge_depart (struct ast_channel *chan)
 Depart a channel from a bridge. More...
 
int ast_bridge_destroy (struct ast_bridge *bridge, int cause)
 Destroy a bridge. More...
 
void ast_bridge_features_remove (struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags)
 Remove marked bridge channel feature hooks. More...
 
struct ast_bridgeast_bridge_find_by_id (const char *bridge_id)
 Find bridge by id. More...
 
int ast_bridge_impart (struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
 Impart a channel to a bridge (non-blocking) More...
 
int ast_bridge_is_video_src (struct ast_bridge *bridge, struct ast_channel *chan)
 Determine if a channel is a video src for the bridge. More...
 
int ast_bridge_join (struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args, enum ast_bridge_join_flags flags)
 Join a channel to a bridge (blocking) More...
 
int ast_bridge_kick (struct ast_bridge *bridge, struct ast_channel *chan)
 Kick a channel from a bridge. More...
 
int ast_bridge_merge (struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, int merge_best_direction, struct ast_channel **kick_me, unsigned int num_kick)
 Merge two bridges together. More...
 
void ast_bridge_merge_inhibit (struct ast_bridge *bridge, int request)
 Adjust the bridge merge inhibit request count. More...
 
int ast_bridge_move (struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_channel *chan, struct ast_channel *swap, int attempt_recovery)
 Move a channel from one bridge to another. More...
 
void ast_bridge_notify_masquerade (struct ast_channel *chan)
 Notify bridging that this channel was just masqueraded. More...
 
int ast_bridge_number_video_src (struct ast_bridge *bridge)
 Returns the number of video sources currently active in the bridge.
 
struct ast_channelast_bridge_peer (struct ast_bridge *bridge, struct ast_channel *chan)
 Get the channel's bridge peer only if the bridge is two-party. More...
 
struct ast_channelast_bridge_peer_nolock (struct ast_bridge *bridge, struct ast_channel *chan)
 Get the channel's bridge peer only if the bridge is two-party. More...
 
struct ao2_containerast_bridge_peers (struct ast_bridge *bridge)
 Get a container of all channels in the bridge. More...
 
struct ao2_containerast_bridge_peers_nolock (struct ast_bridge *bridge)
 Get a container of all channels in the bridge. More...
 
int ast_bridge_queue_action (struct ast_bridge *bridge, struct ast_frame *action)
 Put an action onto the specified bridge. More...
 
int ast_bridge_queue_everyone_else (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 Queue the given frame to everyone else. More...
 
int ast_bridge_remove (struct ast_bridge *bridge, struct ast_channel *chan)
 Remove a channel from a bridge. More...
 
void ast_bridge_remove_video_src (struct ast_bridge *bridge, struct ast_channel *chan)
 remove a channel as a source of video for the bridge.
 
void ast_bridge_set_binaural_active (struct ast_bridge *bridge, unsigned int binaural_active)
 Activates the use of binaural signals in a conference bridge. More...
 
void ast_bridge_set_internal_sample_rate (struct ast_bridge *bridge, unsigned int sample_rate)
 Adjust the internal mixing sample rate of a bridge used during multimix mode. More...
 
void ast_bridge_set_maximum_sample_rate (struct ast_bridge *bridge, unsigned int sample_rate)
 Adjust the maximum mixing sample rate of a bridge used during multimix mode. More...
 
void ast_bridge_set_mixing_interval (struct ast_bridge *bridge, unsigned int mixing_interval)
 Adjust the internal mixing interval of a bridge used during multimix mode. More...
 
void ast_bridge_set_remb_estimated_bitrate (struct ast_bridge *bridge, float estimated_bitrate)
 Force the REMB report estimated bitrate to a specific max value. More...
 
void ast_bridge_set_remb_send_interval (struct ast_bridge *bridge, unsigned int remb_send_interval)
 Set the interval at which a combined REMB frame will be sent to video sources. More...
 
void ast_bridge_set_send_sdp_label (struct ast_bridge *bridge, unsigned int send_sdp_label)
 Controls whether to send a "label" attribute in each stream in an SDP. More...
 
void ast_bridge_set_sfu_video_mode (struct ast_bridge *bridge)
 Set the bridge to be a selective forwarding unit.
 
void ast_bridge_set_single_src_video_mode (struct ast_bridge *bridge, struct ast_channel *video_src_chan)
 Set a bridge to feed a single video source to all participants.
 
void ast_bridge_set_talker_src_video_mode (struct ast_bridge *bridge)
 Set the bridge to pick the strongest talker supporting video as the single source video feed.
 
void ast_bridge_set_transfer_variables (struct ast_channel *chan, const char *value, int is_attended)
 Set the relevant transfer variables for a single channel. More...
 
void ast_bridge_set_video_update_discard (struct ast_bridge *bridge, unsigned int video_update_discard)
 Set the amount of time to discard subsequent video updates after a video update has been sent. More...
 
int ast_bridge_suspend (struct ast_bridge *bridge, struct ast_channel *chan)
 Suspend a channel temporarily from a bridge. More...
 
struct ast_bridgeast_bridge_transfer_acquire_bridge (struct ast_channel *chan)
 Acquire the channel's bridge for transfer purposes. More...
 
enum ast_transfer_result ast_bridge_transfer_attended (struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
 Attended transfer. More...
 
enum ast_transfer_result ast_bridge_transfer_blind (int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
 Blind transfer target to the extension and context provided. More...
 
int ast_bridge_unreal_optimize_out (struct ast_channel *chan, struct ast_channel *peer, struct ast_unreal_pvt *pvt)
 Check and optimize out the unreal channels between bridges. More...
 
int ast_bridge_unsuspend (struct ast_bridge *bridge, struct ast_channel *chan)
 Unsuspend a channel from a bridge. More...
 
void ast_bridge_update_talker_src_video_mode (struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyframe)
 Update information about talker energy for talker src video mode.
 
void ast_bridge_vars_set (struct ast_channel *chan, const char *name, const char *pvtid)
 Sets BRIDGECHANNEL and BRIDGEPVTCALLID for a channel. More...
 
const char * ast_bridge_video_mode_to_string (enum ast_bridge_video_mode_type video_mode)
 Converts an enum representation of a bridge video mode to string. More...
 
struct ao2_containerast_bridges (void)
 Returns the global bridges container. More...
 
enum ast_bridge_optimization ast_bridges_allow_optimization (struct ast_bridge *chan_bridge, struct ast_bridge *peer_bridge)
 Determine if bridges allow for optimization to occur betweem them. More...
 
void ast_brige_set_remb_behavior (struct ast_bridge *bridge, enum ast_bridge_video_sfu_remb_behavior behavior)
 Set the REMB report generation behavior on a bridge. More...
 

Variables

struct ast_bridge_methods ast_bridge_base_v_table
 Bridge base class virtual method table.
 

Detailed Description

Bridging API.

Author
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om Bridging API

See Also:

Definition in file bridge.h.

Macro Definition Documentation

#define ast_bridge_lock (   bridge)    _ast_bridge_lock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)
#define ast_bridge_trylock (   bridge)    _ast_bridge_trylock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)

Try locking the bridge.

Parameters
bridgeBridge to try locking
Return values
0on success.
non-zeroon error.

Definition at line 459 of file bridge.h.

#define ast_bridge_unlock (   bridge)    _ast_bridge_unlock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge)

Unlock the bridge.

Parameters
bridgeBridge to unlock

Definition at line 481 of file bridge.h.

Referenced by ast_ari_bridges_clear_video_source(), ast_ari_bridges_create(), ast_ari_bridges_create_with_id(), ast_bridge_add_channel(), ast_bridge_basic_set_flags(), ast_bridge_channel_feature_digit(), ast_bridge_channel_lock_bridge(), ast_bridge_channel_merge_inhibit(), ast_bridge_destroy(), ast_bridge_get_snapshot(), ast_bridge_get_snapshot_by_uniqueid(), ast_bridge_is_video_src(), ast_bridge_join(), ast_bridge_kick(), ast_bridge_merge(), ast_bridge_merge_inhibit(), ast_bridge_move(), ast_bridge_notify_masquerade(), ast_bridge_number_video_src(), ast_bridge_peer(), ast_bridge_peers(), ast_bridge_remove(), ast_bridge_remove_video_src(), ast_bridge_set_binaural_active(), ast_bridge_set_internal_sample_rate(), ast_bridge_set_maximum_sample_rate(), ast_bridge_set_mixing_interval(), ast_bridge_set_remb_estimated_bitrate(), ast_bridge_set_remb_send_interval(), ast_bridge_set_send_sdp_label(), ast_bridge_set_sfu_video_mode(), ast_bridge_set_single_src_video_mode(), ast_bridge_set_talker_src_video_mode(), ast_bridge_set_video_update_discard(), ast_bridge_suspend(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), ast_bridge_unreal_optimize_out(), ast_bridge_unsuspend(), ast_bridge_update_talker_src_video_mode(), ast_brige_set_remb_behavior(), ast_unreal_channel_push_to_bridge(), attended_transfer_bridge(), bridge_basic_change_personality(), bridge_hold(), bridge_merge(), bridge_move(), bridge_register(), bridge_ringing(), bridge_unhold(), check_binaural_position_change(), conf_moh_start(), conf_moh_stop(), and softmix_mixing_loop().

Typedef Documentation

typedef void(* ast_bridge_destructor_fn) (struct ast_bridge *self)

Destroy the bridge.

Parameters
selfBridge to operate upon.

Definition at line 176 of file bridge.h.

typedef void(* ast_bridge_dissolving_fn) (struct ast_bridge *self)

The bridge is being dissolved.

Parameters
selfBridge to operate upon.

The bridge is being dissolved. Remove any external references to the bridge so it can be destroyed.

Note
On entry, self must NOT be locked.

Definition at line 189 of file bridge.h.

typedef int(* ast_bridge_merge_priority_fn) (struct ast_bridge *self)

Get the merge priority of this bridge.

Parameters
selfBridge to operate upon.
Note
On entry, self is already locked.
Returns
Merge priority

Definition at line 249 of file bridge.h.

typedef void(* ast_bridge_notify_masquerade_fn) (struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)

Notify the bridge that this channel was just masqueraded.

Parameters
selfBridge to operate upon.
bridge_channelBridge channel that was masqueraded.

A masquerade just happened to this channel. The bridge needs to re-evaluate this a channel in the bridge.

Note
On entry, self is already locked.

Definition at line 238 of file bridge.h.

typedef void(* ast_bridge_pull_channel_fn) (struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)

Pull this channel from the bridge.

Parameters
selfBridge to operate upon.
bridge_channelBridge channel to pull.

Remove any channel hooks controlled by the bridge. Release any resources held by bridge_channel->bridge_pvt and release bridge_channel->bridge_pvt.

Note
On entry, self is already locked.

Definition at line 224 of file bridge.h.

typedef int(* ast_bridge_push_channel_fn) (struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)

Push this channel into the bridge.

Parameters
selfBridge to operate upon.
bridge_channelBridge channel to push.
swapBridge channel to swap places with if not NULL.

Setup any channel hooks controlled by the bridge. Allocate bridge_channel->bridge_pvt and initialize any resources put in bridge_channel->bridge_pvt if needed. If there is a swap channel, use it as a guide to setting up the bridge_channel.

Note
On entry, self is already locked.
Return values
0on success.
-1on failure. The channel did not get pushed.

Definition at line 209 of file bridge.h.

typedef void(* transfer_channel_cb) (struct ast_channel *chan, struct transfer_channel_data *user_data, enum ast_transfer_type transfer_type)

Callback function type called during blind transfers.

A caller of ast_bridge_transfer_blind() may wish to set data on the channel that ends up running dialplan. For instance, it may be useful to set channel variables on the channel.

Parameters
chanThe involved channel
user_dataUser-provided data needed in the callback
transfer_typeThe type of transfer being completed

Definition at line 1143 of file bridge.h.

Enumeration Type Documentation

Capabilities for a bridge technology.

Enumerator
AST_BRIDGE_CAPABILITY_HOLDING 

Bridge technology can service calls on hold.

AST_BRIDGE_CAPABILITY_EARLY 

Bridge waits for channel to answer. Passes early media. (XXX Not supported yet)

AST_BRIDGE_CAPABILITY_NATIVE 

Bridge is capable of natively bridging two channels. (Smart bridge only)

AST_BRIDGE_CAPABILITY_1TO1MIX 

Bridge is capable of mixing at most two channels. (Smart bridgeable)

AST_BRIDGE_CAPABILITY_MULTIMIX 

Bridge is capable of mixing an arbitrary number of channels. (Smart bridgeable)

Definition at line 84 of file bridge.h.

84  {
85  /*! Bridge technology can service calls on hold. */
87  /*! Bridge waits for channel to answer. Passes early media. (XXX Not supported yet) */
88  AST_BRIDGE_CAPABILITY_EARLY = (1 << 1),
89  /*! Bridge is capable of natively bridging two channels. (Smart bridge only) */
91  /*! Bridge is capable of mixing at most two channels. (Smart bridgeable) */
93  /*! Bridge is capable of mixing an arbitrary number of channels. (Smart bridgeable) */
95 };
Enumerator
AST_BRIDGE_IMPART_CHAN_MASK 

Field describing what the caller can do with the channel after it is imparted.

AST_BRIDGE_IMPART_CHAN_DEPARTABLE 

The caller wants to reclaim the channel using ast_bridge_depart().

AST_BRIDGE_IMPART_CHAN_INDEPENDENT 

The caller is passing channel control entirely to the bridging system.

AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP 

The initial bridge join does not cause a COLP exchange.

Definition at line 584 of file bridge.h.

584  {
585  /*! Field describing what the caller can do with the channel after it is imparted. */
586  AST_BRIDGE_IMPART_CHAN_MASK = (1 << 0),
587  /*! The caller wants to reclaim the channel using ast_bridge_depart(). */
589  /*! The caller is passing channel control entirely to the bridging system. */
591  /*! The initial bridge join does not cause a COLP exchange. */
593 };
Enumerator
AST_BRIDGE_JOIN_PASS_REFERENCE 

The bridge reference is being passed by the caller.

AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP 

The initial bridge join does not cause a COLP exchange.

Definition at line 533 of file bridge.h.

533  {
534  /*! The bridge reference is being passed by the caller. */
536  /*! The initial bridge join does not cause a COLP exchange. */
538 };

Tells, if optimization is allowed, how the optimization would be performed.

Enumerator
AST_BRIDGE_OPTIMIZE_SWAP_TO_CHAN_BRIDGE 

Optimization would swap peer into the chan_bridge

AST_BRIDGE_OPTIMIZE_SWAP_TO_PEER_BRIDGE 

Optimization would swap chan into the peer_bridge

AST_BRIDGE_OPTIMIZE_MERGE_TO_CHAN_BRIDGE 

Optimization would merge peer_bridge into chan_bridge

AST_BRIDGE_OPTIMIZE_MERGE_TO_PEER_BRIDGE 

Optimization would merge chan_bridge into peer_bridge

AST_BRIDGE_OPTIMIZE_PROHIBITED 

Optimization is not permitted on one or both bridges

Definition at line 874 of file bridge.h.

874  {
875  /*! Optimization would swap peer into the chan_bridge */
877  /*! Optimization would swap chan into the peer_bridge */
879  /*! Optimization would merge peer_bridge into chan_bridge */
881  /*! Optimization would merge chan_bridge into peer_bridge */
883  /*! Optimization is not permitted on one or both bridges */
885 };

Video source modes.

Enumerator
AST_BRIDGE_VIDEO_MODE_NONE 

Video is not allowed in the bridge

AST_BRIDGE_VIDEO_MODE_SINGLE_SRC 

A single user is picked as the only distributed of video across the bridge

AST_BRIDGE_VIDEO_MODE_TALKER_SRC 

A single user's video feed is distributed to all bridge channels, but that feed is automatically picked based on who is talking the most.

AST_BRIDGE_VIDEO_MODE_SFU 

Operate as a selective forwarding unit. Video from each participant is cloned to a dedicated stream on a subset of the remaining participants.

Definition at line 98 of file bridge.h.

98  {
99  /*! Video is not allowed in the bridge */
101  /*! A single user is picked as the only distributed of video across the bridge */
103  /*! A single user's video feed is distributed to all bridge channels, but
104  * that feed is automatically picked based on who is talking the most. */
106  /*! Operate as a selective forwarding unit. Video from each participant is
107  * cloned to a dedicated stream on a subset of the remaining participants.
108  */
110 };

REMB report behaviors.

Enumerator
AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE 

The average of all reports is sent to the sender

AST_BRIDGE_VIDEO_SFU_REMB_LOWEST 

The lowest reported bitrate is forwarded to the sender

AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST 

The highest reported bitrate is forwarded to the sender

AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE_ALL 

The average of all reports WITHIN the bridge is sent to each sender

AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL 

The lowest reported bitrate from all channels in the bridge is forwarded to each sender

AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL 

The highest reported bitrate from all channels in the bridge is forwarded to each sender

AST_BRIDGE_VIDEO_SFU_REMB_FORCE 

Force the REMB estimated bitrate to a specified value

Definition at line 131 of file bridge.h.

131  {
132  /*! The average of all reports is sent to the sender */
134  /*! The lowest reported bitrate is forwarded to the sender */
136  /*! The highest reported bitrate is forwarded to the sender */
138  /*! The average of all reports WITHIN the bridge is sent to each sender */
140  /*! The lowest reported bitrate from all channels in the bridge is forwarded to each sender */
142  /*! The highest reported bitrate from all channels in the bridge is forwarded to each sender */
144  /*! Force the REMB estimated bitrate to a specified value */
146 };
Enumerator
AST_BRIDGE_TRANSFER_SUCCESS 

The transfer completed successfully

AST_BRIDGE_TRANSFER_NOT_PERMITTED 

A bridge involved does not permit transferring

AST_BRIDGE_TRANSFER_INVALID 

The current bridge setup makes transferring an invalid operation

AST_BRIDGE_TRANSFER_FAIL 

The transfer operation failed for a miscellaneous reason

Definition at line 1098 of file bridge.h.

1098  {
1099  /*! The transfer completed successfully */
1101  /*! A bridge involved does not permit transferring */
1103  /*! The current bridge setup makes transferring an invalid operation */
1105  /*! The transfer operation failed for a miscellaneous reason */
1107 };
Enumerator
AST_BRIDGE_TRANSFER_SINGLE_PARTY 

Transfer of a single party

AST_BRIDGE_TRANSFER_MULTI_PARTY 

Transfer of multiple parties

Definition at line 1109 of file bridge.h.

1109  {
1110  /*! Transfer of a single party */
1112  /*! Transfer of multiple parties */
1114 };

Function Documentation

struct ast_bridge* ast_bridge_base_new ( uint32_t  capabilities,
unsigned int  flags,
const char *  creator,
const char *  name,
const char *  id 
)

Create a new base class bridge.

Parameters
capabilitiesThe capabilities that we require to be used on the bridge
flagsFlags that will alter the behavior of the bridge
creatorEntity that created the bridge (optional)
nameName given to the bridge by its creator (optional, requires named creator)
idUnique ID given to the bridge by its creator (optional)
Returns
a pointer to a new bridge on success
Return values
NULLon failure

Example usage:

1 struct ast_bridge *bridge;
2 bridge = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE_HANGUP);

This creates a no frills two party bridge that will be destroyed once one of the channels hangs up.

Definition at line 934 of file bridge.c.

References bridge_base_init(), and bridge_register().

Referenced by join_conference_bridge().

935 {
936  void *bridge;
937 
938  bridge = bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_base_v_table);
939  bridge = bridge_base_init(bridge, capabilities, flags, creator, name, id);
940  bridge = bridge_register(bridge);
941  return bridge;
942 }
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
Definition: bridge.c:923
struct ast_flags flags
struct ast_bridge * bridge_register(struct ast_bridge *bridge)
Register the new bridge with the system.
Definition: bridge.c:691
Structure that contains information about a bridge.
Definition: bridge.h:349
const ast_string_field name
struct ast_bridge * bridge
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
int ast_bridge_depart ( struct ast_channel chan)

Depart a channel from a bridge.

Parameters
chanChannel to depart
Note
chan is locked by this function.
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_depart(chan);

This removes the channel pointed to by the chan pointer from any bridge it may be in and gives control to the calling thread. This does not hang up the channel.

Note
This API call can only be used on channels that were added to the bridge using the ast_bridge_impart API call with the AST_BRIDGE_IMPART_CHAN_DEPARTABLE flag.

Definition at line 1906 of file bridge.c.

References ao2_ref, ast_bridge_channel_leave_bridge(), ast_debug, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, ast_bridge_channel::chan, ast_bridge_channel::depart_wait, and ast_bridge_channel::thread.

Referenced by control_swap_channel_in_bridge(), depart_channel(), and stasis_app_exec().

1907 {
1908  struct ast_bridge_channel *bridge_channel;
1909  int departable;
1910  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
1911 
1912  ast_channel_lock(chan);
1913  bridge_channel = ast_channel_internal_bridge_channel(chan);
1914  departable = bridge_channel && bridge_channel->depart_wait;
1915  ast_channel_unlock(chan);
1916  if (!departable) {
1917  ast_log(LOG_ERROR, "Channel %s cannot be departed.\n",
1918  ast_channel_name(chan));
1919  /*
1920  * Should never happen. It likely means that
1921  * ast_bridge_depart() is called by two threads for the same
1922  * channel, the channel was never imparted to be departed, or it
1923  * has already been departed.
1924  */
1925  ast_assert(0);
1926  return -1;
1927  }
1928 
1929  /*
1930  * We are claiming the bridge_channel reference held by
1931  * bridge_channel_depart_thread().
1932  */
1933 
1934  ast_bridge_channel_leave_bridge(bridge_channel,
1935  BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, AST_CAUSE_NORMAL_CLEARING);
1936 
1937  /* Wait for the depart thread to die */
1938  ast_debug(1, "Waiting for %p(%s) bridge thread to die.\n",
1939  bridge_channel, ast_channel_name(bridge_channel->chan));
1940  pthread_join(bridge_channel->thread, NULL);
1941 
1942  ast_channel_lock(chan);
1943  ast_channel_internal_bridge_channel_set(chan, NULL);
1944  ast_channel_unlock(chan);
1945 
1946  /* We can get rid of the bridge_channel after the depart thread has died. */
1947  ao2_ref(bridge_channel, -1);
1948  return 0;
1949 }
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ast_debug(level,...)
Log a DEBUG message.
void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
Set bridge channel state to leave bridge (if not leaving already).
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
unsigned int depart_wait
int ast_bridge_destroy ( struct ast_bridge bridge,
int  cause 
)

Destroy a bridge.

Parameters
bridgeBridge to destroy
causeCause of bridge being destroyed. (If cause <= 0 then use AST_CAUSE_NORMAL_CLEARING)
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_destroy(bridge, AST_CAUSE_NORMAL_CLEARING);

This destroys a bridge that was previously created.

Note
While this function will kick all channels out of the bridge, channels that were added to the bridge using ast_bridge_impart() with the flag AST_BRIDGE_IMPART_CHAN_DEPARTABLE set must have ast_bridge_depart() called on them.

Definition at line 944 of file bridge.c.

References ao2_ref, ast_bridge_lock, ast_bridge_unlock, ast_debug, and ast_bridge::uniqueid.

Referenced by action_bridge(), agent_request_exec(), ast_bridge_call_with_flags(), attended_transfer_properties_shutdown(), bridge_exec(), bridge_register(), destroy_conference_bridge(), stasis_app_bridge_destroy(), and stasis_app_control_shutdown().

945 {
946  ast_debug(1, "Bridge %s: telling all channels to leave the party\n", bridge->uniqueid);
947  ast_bridge_lock(bridge);
948  bridge_dissolve(bridge, cause);
949  ast_bridge_unlock(bridge);
950 
951  ao2_ref(bridge, -1);
952 
953  return 0;
954 }
const ast_string_field uniqueid
Definition: bridge.h:401
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
void ast_bridge_features_remove ( struct ast_bridge_features features,
enum ast_bridge_hook_remove_flags  flags 
)

Remove marked bridge channel feature hooks.

Since
12.0.0
Parameters
featuresBridge features structure
flagsDeterminator for whether hook is removed.

Definition at line 3501 of file bridge.c.

References ast_bridge_features::dtmf_hooks, ast_bridge_features::interval_hooks, and ast_bridge_features::other_hooks.

Referenced by remove_hooks_on_personality_change().

3502 {
3503  hooks_remove_container(features->dtmf_hooks, remove_flags);
3504  hooks_remove_container(features->other_hooks, remove_flags);
3505  hooks_remove_heap(features->interval_hooks, remove_flags);
3506 }
struct ao2_container * dtmf_hooks
struct ast_heap * interval_hooks
struct ao2_container * other_hooks
struct ast_bridge* ast_bridge_find_by_id ( const char *  bridge_id)

Find bridge by id.

Since
12.0.0
Parameters
bridge_idBridge identifier
Returns
NULL bridge not found
non-NULL reference to bridge

Definition at line 5012 of file bridge.c.

References OBJ_SEARCH_KEY.

Referenced by ast_bridge_get_snapshot_by_uniqueid().

5013 {
5014  return ao2_find(bridges, bridge_id, OBJ_SEARCH_KEY);
5015 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
static struct ao2_container * bridges
Definition: bridge.c:123
int ast_bridge_impart ( struct ast_bridge bridge,
struct ast_channel chan,
struct ast_channel swap,
struct ast_bridge_features features,
enum ast_bridge_impart_flags  flags 
)

Impart a channel to a bridge (non-blocking)

Parameters
bridgeBridge to impart on
chanChannel to impart (The channel reference is stolen if impart successful.)
swapChannel to swap out if swapping. NULL if not swapping.
featuresBridge features structure.
flagsdefined by enum ast_bridge_impart_flags.
Note
The given bridge must be unlocked when calling this function.
The features parameter must be NULL or obtained by ast_bridge_features_new(). You must not dereference features after calling even if the call fails.
chan is locked by this function.
Return values
0on success
-1on failure (Caller still has ownership of chan)

Example usage:

1 ast_bridge_impart(bridge, chan, NULL, NULL, AST_BRIDGE_IMPART_CHAN_INDEPENDENT);

This adds a channel pointed to by the chan pointer to the bridge pointed to by the bridge pointer. This function will return immediately and will not wait until the channel is no longer part of the bridge.

If this channel will be replacing another channel the other channel can be specified in the swap parameter. The other channel will be thrown out of the bridge in an atomic fashion.

If channel specific features are enabled, a pointer to the features structure can be specified in the features parameter.

Note
If you impart a channel with AST_BRIDGE_IMPART_CHAN_DEPARTABLE you MUST ast_bridge_depart() the channel if this call succeeds. The bridge channel thread is created join-able. The implication is that the channel is special and will not behave like a normal channel.
If you impart a channel with AST_BRIDGE_IMPART_CHAN_INDEPENDENT you must not ast_bridge_depart() the channel. The bridge channel thread is created non-join-able. The channel must be treated as if it were placed into the bridge by ast_bridge_join(). Channels placed into a bridge by ast_bridge_join() are removed by a third party using ast_bridge_remove().
Any callbacks on the channel will be invoked on failure with the reason as AST_BRIDGE_AFTER_CB_REASON_IMPART_FAILED.

Definition at line 1878 of file bridge.c.

References AST_BRIDGE_AFTER_CB_REASON_IMPART_FAILED, ast_bridge_discard_after_callback(), bridge_channel_impart_cond::cond, bridge_channel_impart_cond::done, bridge_channel_impart_cond::lock, and ast_bridge::uniqueid.

Referenced by add_to_dial_bridge(), ast_bridge_add_channel(), ast_bridge_call_with_flags(), ast_unreal_channel_push_to_bridge(), attended_transfer_bridge(), conf_announce_channel_push(), control_swap_channel_in_bridge(), feature_attended_transfer(), and local_call().

1883 {
1884  struct bridge_channel_impart_cond cond = {
1885  .done = 0,
1886  };
1887  int res;
1888  SCOPE_TRACE(1, "%s Bridge: %s\n", ast_channel_name(chan), bridge->uniqueid);
1889 
1890  ast_mutex_init(&cond.lock);
1891  ast_cond_init(&cond.cond, NULL);
1892 
1893  res = bridge_impart_internal(bridge, chan, swap, features, flags, &cond);
1894  if (res) {
1895  /* Impart failed. Signal any other waiting impart threads */
1897  bridge_channel_impart_signal(chan);
1898  }
1899 
1900  ast_cond_destroy(&cond.cond);
1901  ast_mutex_destroy(&cond.lock);
1902 
1903  return res;
1904 }
Internal bridge impart wait condition and associated conditional.
Definition: bridge.c:1475
const ast_string_field uniqueid
Definition: bridge.h:401
void ast_bridge_discard_after_callback(struct ast_channel *chan, enum ast_bridge_after_cb_reason reason)
Run discarding any after bridge callbacks.
Definition: bridge_after.c:239
int ast_bridge_is_video_src ( struct ast_bridge bridge,
struct ast_channel chan 
)

Determine if a channel is a video src for the bridge.

Return values
0Not a current video source of the bridge.
non-zerois a video source of the bridge, The number returned represents the priority this video stream has on the bridge where 1 is the highest priority.

Definition at line 3891 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_NONE, AST_BRIDGE_VIDEO_MODE_SFU, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, ast_bridge_video_talker_src_data::chan_old_vsrc, ast_bridge_video_single_src_data::chan_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

3892 {
3893  int res = 0;
3894 
3895  ast_bridge_lock(bridge);
3896  switch (bridge->softmix.video_mode.mode) {
3898  break;
3900  if (bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc == chan) {
3901  res = 1;
3902  }
3903  break;
3905  if (bridge->softmix.video_mode.mode_data.talker_src_data.chan_vsrc == chan) {
3906  res = 1;
3907  } else if (bridge->softmix.video_mode.mode_data.talker_src_data.chan_old_vsrc == chan) {
3908  res = 2;
3909  }
3911  break;
3912  }
3913  ast_bridge_unlock(bridge);
3914  return res;
3915 }
struct ast_bridge_video_mode video_mode
Definition: bridge.h:279
struct ast_channel * chan_old_vsrc
Definition: bridge.h:127
struct ast_channel * chan_vsrc
Definition: bridge.h:116
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#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 ast_channel * chan_vsrc
Definition: bridge.h:123
int ast_bridge_join ( struct ast_bridge bridge,
struct ast_channel chan,
struct ast_channel swap,
struct ast_bridge_features features,
struct ast_bridge_tech_optimizations tech_args,
enum ast_bridge_join_flags  flags 
)

Join a channel to a bridge (blocking)

Parameters
bridgeBridge to join
chanChannel to join
swapChannel to swap out if swapping (A channel reference is stolen.)
featuresBridge features structure
tech_argsOptional Bridging tech optimization parameters for this channel.
flagsdefined by enum ast_bridge_join_flags.
Note
The passed in swap channel is always unreffed on return. It is not a good idea to access the swap channel on return or for the caller to keep a reference to it.
Absolutely NO locks should be held before calling this function since it blocks.
Return values
0if the channel successfully joined the bridge before it exited.
-1if the channel failed to join the bridge

Example usage:

1 ast_bridge_join(bridge, chan, NULL, NULL, NULL, AST_BRIDGE_JOIN_PASS_REFERENCE);

This adds a channel pointed to by the chan pointer to the bridge pointed to by the bridge pointer. This function will not return until the channel has been removed from the bridge, swapped out for another channel, or has hung up.

If this channel will be replacing another channel the other channel can be specified in the swap parameter. The other channel will be thrown out of the bridge in an atomic fashion.

If channel specific features are enabled a pointer to the features structure can be specified in the features parameter.

Definition at line 1621 of file bridge.c.

References ao2_ref, AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP, AST_BRIDGE_JOIN_PASS_REFERENCE, ast_bridge_lock, ast_bridge_run_after_callback(), ast_bridge_setup_after_goto(), ast_bridge_unlock, AST_FLAG_ZOMBIE, AST_SOFTHANGUP_ASYNCGOTO, ast_softhangup_nolock(), ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_channel::inhibit_colp, ast_bridge_methods::push_peek, ast_bridge_channel::swap, ast_bridge_channel::tech_args, ast_bridge_channel::thread, ast_bridge::uniqueid, and ast_bridge::v_table.

Referenced by agent_request_exec(), ast_bridge_call_with_flags(), bridge_exec(), and confbridge_exec().

1627 {
1628  struct ast_bridge_channel *bridge_channel;
1629  int res = 0;
1630  SCOPE_TRACE(1, "%s Bridge: %s\n", ast_channel_name(chan), bridge->uniqueid);
1631 
1632  bridge_channel = bridge_channel_internal_alloc(bridge);
1633  if (flags & AST_BRIDGE_JOIN_PASS_REFERENCE) {
1634  ao2_ref(bridge, -1);
1635  }
1636  if (!bridge_channel) {
1637  ao2_t_cleanup(swap, "Error exit: bridge_channel alloc failed");
1638  res = -1;
1639  goto join_exit;
1640  }
1641 /* XXX ASTERISK-21271 features cannot be NULL when passed in. When it is changed to allocated we can do like ast_bridge_impart() and allocate one. */
1642  ast_assert(features != NULL);
1643  if (!features) {
1644  ao2_ref(bridge_channel, -1);
1645  ao2_t_cleanup(swap, "Error exit: features is NULL");
1646  res = -1;
1647  goto join_exit;
1648  }
1649  if (tech_args) {
1650  bridge_channel->tech_args = *tech_args;
1651  }
1652 
1653  ast_channel_lock(chan);
1654  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) {
1655  res = -1;
1656  } else {
1657  ast_channel_internal_bridge_channel_set(chan, bridge_channel);
1658  }
1659  ast_channel_unlock(chan);
1660  bridge_channel->thread = pthread_self();
1661  bridge_channel->chan = chan;
1662  bridge_channel->swap = swap;
1663  bridge_channel->features = features;
1664  bridge_channel->inhibit_colp = !!(flags & AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP);
1665 
1666  /* allow subclass to peek at upcoming push operation */
1667  if (bridge->v_table->push_peek && !res) {
1668  struct ast_bridge_channel *bcswap = NULL;
1669 
1670  ast_bridge_lock(bridge);
1671  if (bridge_channel->swap) {
1672  bcswap = bridge_find_channel(bridge, bridge_channel->swap);
1673  }
1674  res = bridge->v_table->push_peek(bridge, bridge_channel, bcswap);
1675  ast_bridge_unlock(bridge);
1676  }
1677 
1678  if (!res) {
1679  res = bridge_channel_internal_join(bridge_channel);
1680  }
1681 
1682  /* Cleanup all the data in the bridge channel after it leaves the bridge. */
1683  ast_channel_lock(chan);
1684  ast_channel_internal_bridge_channel_set(chan, NULL);
1685  ast_channel_unlock(chan);
1686  /* Due to a race condition, we lock the bridge channel here for ast_bridge_channel_get_chan */
1687  ao2_lock(bridge_channel);
1688  bridge_channel->chan = NULL;
1689  ao2_unlock(bridge_channel);
1690  /* If bridge_channel->swap is not NULL then the join failed. */
1691  ao2_t_cleanup(bridge_channel->swap, "Bridge complete: join failed");
1692  bridge_channel->swap = NULL;
1693  bridge_channel->features = NULL;
1694 
1695  ao2_ref(bridge_channel, -1);
1696 
1697 join_exit:
1699  bridge_channel_impart_signal(chan);
1700  if (!(ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO)
1701  && !ast_bridge_setup_after_goto(chan)) {
1702  /* Claim the after bridge goto is an async goto destination. */
1703  ast_channel_lock(chan);
1704  ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
1705  ast_channel_unlock(chan);
1706  }
1707  return res;
1708 }
const ast_string_field uniqueid
Definition: bridge.h:401
struct ast_bridge_features * features
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
const struct ast_bridge_methods * v_table
Definition: bridge.h:351
struct ast_bridge_tech_optimizations tech_args
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
void ast_bridge_run_after_callback(struct ast_channel *chan)
Run any after bridge callback.
Definition: bridge_after.c:212
unsigned int inhibit_colp
struct ast_channel * swap
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
ast_bridge_push_channel_fn push_peek
Definition: bridge.h:273
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2458
int ast_bridge_setup_after_goto(struct ast_channel *chan)
Setup any after bridge goto location to begin execution.
Definition: bridge_after.c:435
int ast_bridge_kick ( struct ast_bridge bridge,
struct ast_channel chan 
)

Kick a channel from a bridge.

Parameters
bridgeBridge that the channel is to be kicked from
chanChannel to kick
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_kick(bridge, chan);

This kicks the channel pointed to by the chan pointer from the bridge pointed to by the bridge pointer and requests that it be hung up. Control over the channel will NOT be given to the calling thread.

Note
The functional difference between ast_bridge_kick() and ast_bridge_remove() is that the bridge may dissolve as a result of the channel being kicked.
This API call can be used on channels that were added to the bridge using both ast_bridge_join and ast_bridge_impart.

Definition at line 1979 of file bridge.c.

References ast_bridge_channel_queue_callback(), ast_bridge_lock, and ast_bridge_unlock.

1980 {
1981  struct ast_bridge_channel *bridge_channel;
1982  int res;
1983 
1984  ast_bridge_lock(bridge);
1985 
1986  /* Try to find the channel that we want to kick. */
1987  if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
1988  ast_bridge_unlock(bridge);
1989  return -1;
1990  }
1991 
1992  res = ast_bridge_channel_queue_callback(bridge_channel, 0, kick_it, NULL, 0);
1993 
1994  ast_bridge_unlock(bridge);
1995 
1996  return res;
1997 }
int ast_bridge_channel_queue_callback(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_custom_callback_option flags, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
Queue a bridge action custom callback frame onto the bridge channel.
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Structure that contains information regarding a channel in a bridge.
int ast_bridge_merge ( struct ast_bridge dst_bridge,
struct ast_bridge src_bridge,
int  merge_best_direction,
struct ast_channel **  kick_me,
unsigned int  num_kick 
)

Merge two bridges together.

Parameters
dst_bridgeDestination bridge of merge.
src_bridgeSource bridge of merge.
merge_best_directionTRUE if don't care about which bridge merges into the other.
kick_meArray of channels to kick from the bridges.
num_kickNumber of channels in the kick_me array.
Note
Absolutely NO bridge or channel locks should be held before calling this function.
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_merge(dst_bridge, src_bridge, 0, NULL, 0);

This moves the channels in src_bridge into the bridge pointed to by dst_bridge.

Definition at line 2300 of file bridge.c.

References ast_bridge_lock_both, and ast_bridge_unlock.

2301 {
2302  int res;
2303 
2304  /* Sanity check. */
2305  ast_assert(dst_bridge && src_bridge);
2306 
2307  ast_bridge_lock_both(dst_bridge, src_bridge);
2308  res = bridge_merge_locked(dst_bridge, src_bridge, merge_best_direction, kick_me, num_kick);
2309  ast_bridge_unlock(src_bridge);
2310  ast_bridge_unlock(dst_bridge);
2311  return res;
2312 }
#define ast_bridge_lock_both(bridge1, bridge2)
Lock two bridges.
Definition: bridge.h:488
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
void ast_bridge_merge_inhibit ( struct ast_bridge bridge,
int  request 
)

Adjust the bridge merge inhibit request count.

Since
12.0.0
Parameters
bridgeWhat to operate on.
requestInhibit request increment. (Positive to add requests. Negative to remove requests.)

Definition at line 3000 of file bridge.c.

References ast_bridge_lock, and ast_bridge_unlock.

Referenced by attended_transfer_properties_shutdown(), and feature_attended_transfer().

3001 {
3002  ast_bridge_lock(bridge);
3003  bridge_merge_inhibit_nolock(bridge, request);
3004  ast_bridge_unlock(bridge);
3005 }
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
int ast_bridge_move ( struct ast_bridge dst_bridge,
struct ast_bridge src_bridge,
struct ast_channel chan,
struct ast_channel swap,
int  attempt_recovery 
)

Move a channel from one bridge to another.

Since
12.0.0
Parameters
dst_bridgeDestination bridge of bridge channel move.
src_bridgeSource bridge of bridge channel move.
chanChannel to move.
swapChannel to replace in dst_bridge.
attempt_recoveryTRUE if failure attempts to push channel back into original bridge.
Note
Absolutely NO bridge or channel locks should be held before calling this function.
Return values
0on success.
-1on failure.

Definition at line 2460 of file bridge.c.

References ast_bridge_lock_both, and ast_bridge_unlock.

2461 {
2462  int res;
2463 
2464  ast_bridge_lock_both(dst_bridge, src_bridge);
2465  res = bridge_move_locked(dst_bridge, src_bridge, chan, swap, attempt_recovery);
2466  ast_bridge_unlock(src_bridge);
2467  ast_bridge_unlock(dst_bridge);
2468  return res;
2469 }
#define ast_bridge_lock_both(bridge1, bridge2)
Lock two bridges.
Definition: bridge.h:488
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
void ast_bridge_notify_masquerade ( struct ast_channel chan)

Notify bridging that this channel was just masqueraded.

Since
12.0.0
Parameters
chanChannel just involved in a masquerade

Definition at line 1442 of file bridge.c.

References ao2_ref, ast_bridge_channel_lock_bridge(), ast_bridge_unlock, ast_channel_get_bridge_channel(), ast_bridge_channel::bridge, ast_bridge_methods::notify_masquerade, and ast_bridge::v_table.

Referenced by channel_do_masquerade().

1443 {
1444  struct ast_bridge_channel *bridge_channel;
1445  struct ast_bridge *bridge;
1446 
1447  /* Safely get the bridge_channel pointer for the chan. */
1448  ast_channel_lock(chan);
1449  bridge_channel = ast_channel_get_bridge_channel(chan);
1450  ast_channel_unlock(chan);
1451  if (!bridge_channel) {
1452  /* Not in a bridge */
1453  return;
1454  }
1455 
1456  ast_bridge_channel_lock_bridge(bridge_channel);
1457  bridge = bridge_channel->bridge;
1458  if (bridge_channel == bridge_find_channel(bridge, chan)) {
1459 /*
1460  * XXX ASTERISK-22366 this needs more work. The channels need
1461  * to be made compatible again if the formats change. The
1462  * bridge_channel thread needs to monitor for this case.
1463  */
1464  /* The channel we want to notify is still in a bridge. */
1465  bridge->v_table->notify_masquerade(bridge, bridge_channel);
1466  bridge_reconfigured(bridge, 1);
1467  }
1468  ast_bridge_unlock(bridge);
1469  ao2_ref(bridge_channel, -1);
1470 }
struct ast_bridge * bridge
Bridge this channel is participating in.
ast_bridge_notify_masquerade_fn notify_masquerade
Definition: bridge.h:269
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
const struct ast_bridge_methods * v_table
Definition: bridge.h:351
Structure that contains information about a bridge.
Definition: bridge.h:349
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition: channel.c:10582
Structure that contains information regarding a channel in a bridge.
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
Lock the bridge associated with the bridge channel.
struct ast_channel* ast_bridge_peer ( struct ast_bridge bridge,
struct ast_channel chan 
)

Get the channel's bridge peer only if the bridge is two-party.

Since
12.0.0
Parameters
bridgeThe bridge
chanChannel desiring the bridge peer channel.
Note
The returned peer channel is the current peer in the bridge when called.
Return values
NULLChannel not in a bridge or the bridge is not two-party.
non-NULLReffed peer channel at time of calling.

Definition at line 4075 of file bridge.c.

References ast_bridge_lock, ast_bridge_peer_nolock(), and ast_bridge_unlock.

Referenced by ast_attended_transfer_message_create(), ast_bridge_transfer_blind(), ast_channel_bridge_peer(), and get_transfer_parties_transferer_bridge().

4076 {
4077  struct ast_channel *peer;
4078 
4079  ast_bridge_lock(bridge);
4080  peer = ast_bridge_peer_nolock(bridge, chan);
4081  ast_bridge_unlock(bridge);
4082 
4083  return peer;
4084 }
Main Channel structure associated with a channel.
struct ast_channel * ast_bridge_peer_nolock(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: bridge.c:4047
#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 ast_channel* ast_bridge_peer_nolock ( struct ast_bridge bridge,
struct ast_channel chan 
)

Get the channel's bridge peer only if the bridge is two-party.

Since
12.0.0
Parameters
bridgeThe bridge which is already locked.
chanChannel desiring the bridge peer channel.
Note
The returned peer channel is the current peer in the bridge when called.
Return values
NULLChannel not in a bridge or the bridge is not two-party.
non-NULLReffed peer channel at time of calling.

Definition at line 4047 of file bridge.c.

References AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_CAPABILITY_NATIVE, ast_channel_ref, AST_LIST_TRAVERSE, ast_bridge_technology::capabilities, ast_bridge_channel::chan, ast_bridge::channels, ast_bridge_channel::in_bridge, ast_bridge::num_channels, and ast_bridge::technology.

Referenced by ast_bridge_peer().

4048 {
4049  struct ast_channel *peer = NULL;
4050  struct ast_bridge_channel *iter;
4051 
4052  /* Asking for the peer channel only makes sense on a two-party bridge. */
4053  if (bridge->num_channels == 2
4054  && bridge->technology->capabilities
4056  int in_bridge = 0;
4057 
4058  AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
4059  if (iter->chan != chan) {
4060  peer = iter->chan;
4061  } else {
4062  in_bridge = 1;
4063  }
4064  }
4065  if (in_bridge && peer) {
4066  ast_channel_ref(peer);
4067  } else {
4068  peer = NULL;
4069  }
4070  }
4071 
4072  return peer;
4073 }
Main Channel structure associated with a channel.
struct ast_bridge_technology * technology
Definition: bridge.h:355
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
unsigned int in_bridge
struct ast_bridge_channels_list channels
Definition: bridge.h:363
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2947
Definition: search.h:40
unsigned int num_channels
Definition: bridge.h:373
struct ao2_container* ast_bridge_peers ( struct ast_bridge bridge)

Get a container of all channels in the bridge.

Since
12.0.0
Parameters
bridgeThe bridge
Note
The returned container is a snapshot of channels in the bridge when called.
Return values
NULLFailed to create container
non-NULLContainer of channels in the bridge

Definition at line 4036 of file bridge.c.

References ast_bridge_lock, ast_bridge_peers_nolock(), and ast_bridge_unlock.

4037 {
4038  struct ao2_container *channels;
4039 
4040  ast_bridge_lock(bridge);
4041  channels = ast_bridge_peers_nolock(bridge);
4042  ast_bridge_unlock(bridge);
4043 
4044  return channels;
4045 }
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
struct ao2_container * ast_bridge_peers_nolock(struct ast_bridge *bridge)
Get a container of all channels in the bridge.
Definition: bridge.c:4018
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Generic container type.
struct ao2_container* ast_bridge_peers_nolock ( struct ast_bridge bridge)

Get a container of all channels in the bridge.

Since
12.0.0
Parameters
bridgeThe bridge which is already locked.
Return values
NULLFailed to create container
non-NULLContainer of channels in the bridge

Definition at line 4018 of file bridge.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_hash, ao2_link, AST_LIST_TRAVERSE, ast_bridge_channel::chan, and ast_bridge::channels.

Referenced by ast_bridge_peers(), ast_bridge_transfer_attended(), and ast_bridge_transfer_blind().

4019 {
4020  struct ao2_container *channels;
4021  struct ast_bridge_channel *iter;
4022 
4024  13, channel_hash, NULL, channel_cmp);
4025  if (!channels) {
4026  return NULL;
4027  }
4028 
4029  AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
4030  ao2_link(channels, iter->chan);
4031  }
4032 
4033  return channels;
4034 }
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct ast_bridge_channels_list channels
Definition: bridge.h:363
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
Definition: search.h:40
Generic container type.
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
int ast_bridge_queue_action ( struct ast_bridge bridge,
struct ast_frame action 
)

Put an action onto the specified bridge.

Since
12.0.0
Parameters
bridgeWhat to queue the action on.
actionWhat to do.
Return values
0on success.
-1on error.
Note
This API call is meant for internal bridging operations.

Definition at line 303 of file bridge.c.

References ast_frdup.

304 {
305  struct ast_frame *dup;
306 
307  dup = ast_frdup(action);
308  if (!dup) {
309  return -1;
310  }
311  bridge_queue_action_nodup(bridge, dup);
312  return 0;
313 }
#define ast_frdup(fr)
Copies a frame.
Data structure associated with a single frame of data.
int ast_bridge_queue_everyone_else ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel,
struct ast_frame frame 
)

Queue the given frame to everyone else.

Since
12.0.0
Parameters
bridgeWhat bridge to distribute frame.
bridge_channelChannel to optionally not pass frame to. (NULL to pass to everyone)
frameFrame to pass.
Note
This is intended to be called by bridge hooks and bridge technologies.
Return values
0Frame written to at least one channel.
-1Frame written to no channels.

Definition at line 1083 of file bridge_channel.c.

References ast_bridge_channel_queue_frame(), AST_FRAME_NULL, AST_LIST_TRAVERSE, ast_bridge::channels, and ast_frame::frametype.

Referenced by bridge_hold(), bridge_ringing(), and bridge_unhold().

1084 {
1085  struct ast_bridge_channel *cur;
1086  int not_written = -1;
1087 
1088  if (frame->frametype == AST_FRAME_NULL) {
1089  /* "Accept" the frame and discard it. */
1090  return 0;
1091  }
1092 
1093  AST_LIST_TRAVERSE(&bridge->channels, cur, entry) {
1094  if (cur == bridge_channel) {
1095  continue;
1096  }
1097  if (!ast_bridge_channel_queue_frame(cur, frame)) {
1098  not_written = 0;
1099  }
1100  }
1101  return not_written;
1102 }
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
Write a frame to the specified bridge_channel.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct ast_bridge_channels_list channels
Definition: bridge.h:363
Structure that contains information regarding a channel in a bridge.
Definition: search.h:40
enum ast_frame_type frametype
int ast_bridge_remove ( struct ast_bridge bridge,
struct ast_channel chan 
)

Remove a channel from a bridge.

Parameters
bridgeBridge that the channel is to be removed from
chanChannel to remove
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_remove(bridge, chan);

This removes the channel pointed to by the chan pointer from the bridge pointed to by the bridge pointer and requests that it be hung up. Control over the channel will NOT be given to the calling thread.

Note
This API call can be used on channels that were added to the bridge using both ast_bridge_join and ast_bridge_impart.

Definition at line 1951 of file bridge.c.

References ast_bridge_channel_leave_bridge(), ast_bridge_lock, ast_bridge_unlock, ast_debug, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, and ast_bridge::uniqueid.

Referenced by ast_bridge_transfer_attended(), and ast_bridge_transfer_blind().

1952 {
1953  struct ast_bridge_channel *bridge_channel;
1954 
1955  ast_debug(1, "Removing channel %s from bridge %s\n",
1956  ast_channel_name(chan), bridge->uniqueid);
1957 
1958  ast_bridge_lock(bridge);
1959 
1960  /* Try to find the channel that we want to remove */
1961  if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
1962  ast_bridge_unlock(bridge);
1963  return -1;
1964  }
1965 
1966  ast_bridge_channel_leave_bridge(bridge_channel,
1967  BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, AST_CAUSE_NORMAL_CLEARING);
1968 
1969  ast_bridge_unlock(bridge);
1970 
1971  return 0;
1972 }
const ast_string_field uniqueid
Definition: bridge.h:401
#define ast_debug(level,...)
Log a DEBUG message.
void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
Set bridge channel state to leave bridge (if not leaving already).
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Structure that contains information regarding a channel in a bridge.
void ast_bridge_set_binaural_active ( struct ast_bridge bridge,
unsigned int  binaural_active 
)

Activates the use of binaural signals in a conference bridge.

Parameters
bridgeChannel to activate the binaural signals.
binaural_activeIf true binaural signal processing will be active for the bridge.

Definition at line 3705 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_softmix::binaural_active, and ast_bridge::softmix.

Referenced by join_conference_bridge().

3706 {
3707  ast_bridge_lock(bridge);
3708  bridge->softmix.binaural_active = binaural_active;
3709  ast_bridge_unlock(bridge);
3710 }
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
unsigned int binaural_active
Definition: bridge.h:295
void ast_bridge_set_internal_sample_rate ( struct ast_bridge bridge,
unsigned int  sample_rate 
)

Adjust the internal mixing sample rate of a bridge used during multimix mode.

Parameters
bridgeChannel to change the sample rate on.
sample_ratethe sample rate to change to. If a value of 0 is passed here, the bridge will be free to pick what ever sample rate it chooses.

Definition at line 3712 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_softmix::internal_sample_rate, and ast_bridge::softmix.

Referenced by join_conference_bridge().

3713 {
3714  ast_bridge_lock(bridge);
3715  bridge->softmix.internal_sample_rate = sample_rate;
3716  ast_bridge_unlock(bridge);
3717 }
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
unsigned int internal_sample_rate
The internal sample rate softmix uses to mix channels.
Definition: bridge.h:285
void ast_bridge_set_maximum_sample_rate ( struct ast_bridge bridge,
unsigned int  sample_rate 
)

Adjust the maximum mixing sample rate of a bridge used during multimix mode.

Since
13.31.0
16.8.0
17.2.0
Parameters
bridgeChannel to change the sample rate on.
sample_ratethe maximum sample rate to use. If a value of 0 is passed here, the bridge will be free to pick what ever sample rate it chooses.

Definition at line 3719 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_softmix::maximum_sample_rate, and ast_bridge::softmix.

Referenced by join_conference_bridge().

3720 {
3721  ast_bridge_lock(bridge);
3722  bridge->softmix.maximum_sample_rate = sample_rate;
3723  ast_bridge_unlock(bridge);
3724 }
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
unsigned int maximum_sample_rate
The maximum sample rate softmix uses to mix channels.
Definition: bridge.h:306
void ast_bridge_set_mixing_interval ( struct ast_bridge bridge,
unsigned int  mixing_interval 
)

Adjust the internal mixing interval of a bridge used during multimix mode.

Parameters
bridgeChannel to change the sample rate on.
mixing_intervalthe sample rate to change to. If 0 is set the bridge tech is free to choose any mixing interval it uses by default.

Definition at line 3698 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_softmix::internal_mixing_interval, and ast_bridge::softmix.

Referenced by join_conference_bridge().

3699 {
3700  ast_bridge_lock(bridge);
3701  bridge->softmix.internal_mixing_interval = mixing_interval;
3702  ast_bridge_unlock(bridge);
3703 }
unsigned int internal_mixing_interval
The mixing interval indicates how quickly softmix mixing should occur to mix audio.
Definition: bridge.h:293
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
void ast_bridge_set_remb_estimated_bitrate ( struct ast_bridge bridge,
float  estimated_bitrate 
)

Force the REMB report estimated bitrate to a specific max value.

Parameters
bridgeBridge to set the REMB behavior on
estimated_bitrateThe estimated bitrate in bits per second
Note
This can only be called when the bridge has been set to the SFU video mode.

Definition at line 3807 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, ast_bridge_video_sfu_data::estimated_bitrate, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by join_conference_bridge().

3808 {
3809  ast_assert(bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU);
3810 
3811  ast_bridge_lock(bridge);
3812  bridge->softmix.video_mode.mode_data.sfu_data.estimated_bitrate = estimated_bitrate;
3813  ast_bridge_unlock(bridge);
3814 }
struct ast_bridge_video_mode video_mode
Definition: bridge.h:279
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
void ast_bridge_set_remb_send_interval ( struct ast_bridge bridge,
unsigned int  remb_send_interval 
)

Set the interval at which a combined REMB frame will be sent to video sources.

Parameters
bridgeBridge to set the REMB send interval on
remb_send_intervalThe REMB send interval
Note
This can only be called when the bridge has been set to the SFU video mode.

Definition at line 3789 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, ast_bridge_video_sfu_data::remb_send_interval, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by join_conference_bridge().

3790 {
3791  ast_assert(bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU);
3792 
3793  ast_bridge_lock(bridge);
3794  bridge->softmix.video_mode.mode_data.sfu_data.remb_send_interval = remb_send_interval;
3795  ast_bridge_unlock(bridge);
3796 }
unsigned int remb_send_interval
Definition: bridge.h:151
struct ast_bridge_video_mode video_mode
Definition: bridge.h:279
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
void ast_bridge_set_send_sdp_label ( struct ast_bridge bridge,
unsigned int  send_sdp_label 
)

Controls whether to send a "label" attribute in each stream in an SDP.

Since
16.1.0
Parameters
bridgeThe bridge
send_sdp_labelWhether to send the labels or not
Note
The label will contain the uniqueid of the channel related to the stream. This is used to allow the recipient to correlate the stream to the participant information events sent by app_confbridge. The bridge will be locked in this function.

Definition at line 3966 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_softmix::send_sdp_label, and ast_bridge::softmix.

Referenced by join_conference_bridge().

3967 {
3968  ast_bridge_lock(bridge);
3969  bridge->softmix.send_sdp_label = send_sdp_label;
3970  ast_bridge_unlock(bridge);
3971 }
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
unsigned int send_sdp_label
Definition: bridge.h:300
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
void ast_bridge_set_transfer_variables ( struct ast_channel chan,
const char *  value,
int  is_attended 
)

Set the relevant transfer variables for a single channel.

Sets either the ATTENDEDTRANSFER or BLINDTRANSFER variable for a channel while clearing the opposite.

Parameters
chanChannel the variable is being set for
valueValue the variable is being set to
is_attendedfalse set BLINDTRANSFER and unset ATTENDEDTRANSFER true set ATTENDEDTRANSFER and unset BLINDTRANSFER

Definition at line 4352 of file bridge.c.

References pbx_builtin_setvar_helper().

Referenced by dial_transfer().

4353 {
4354  char *writevar;
4355  char *erasevar;
4356 
4357  if (attended) {
4358  writevar = ATTENDEDTRANSFER;
4359  erasevar = BLINDTRANSFER;
4360  } else {
4361  writevar = BLINDTRANSFER;
4362  erasevar = ATTENDEDTRANSFER;
4363  }
4364 
4365  pbx_builtin_setvar_helper(chan, writevar, value);
4366  pbx_builtin_setvar_helper(chan, erasevar, NULL);
4367 }
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
void ast_bridge_set_video_update_discard ( struct ast_bridge bridge,
unsigned int  video_update_discard 
)

Set the amount of time to discard subsequent video updates after a video update has been sent.

Parameters
bridgeBridge to set the minimum video update wait time on
video_update_discardAmount of time after sending a video update that others should be discarded

Definition at line 3782 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, ast_bridge::softmix, ast_bridge_softmix::video_mode, and ast_bridge_video_mode::video_update_discard.

Referenced by join_conference_bridge().

3783 {
3784  ast_bridge_lock(bridge);
3785  bridge->softmix.video_mode.video_update_discard = video_update_discard;
3786  ast_bridge_unlock(bridge);
3787 }
struct ast_bridge_video_mode video_mode
Definition: bridge.h:279
struct ast_bridge_softmix softmix
Definition: bridge.h:367
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
unsigned int video_update_discard
Definition: bridge.h:168
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
int ast_bridge_suspend ( struct ast_bridge bridge,
struct ast_channel chan 
)

Suspend a channel temporarily from a bridge.

Parameters
bridgeBridge to suspend the channel from
chanChannel to suspend
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_suspend(bridge, chan);

This suspends the channel pointed to by chan from the bridge pointed to by bridge temporarily. Control of the channel is given to the calling thread. This differs from ast_bridge_depart as the channel will not be removed from the bridge.

Note
This API call can be used on channels that were added to the bridge using both ast_bridge_join and ast_bridge_impart.

Definition at line 3007 of file bridge.c.

References ast_bridge_lock, and ast_bridge_unlock.

Referenced by conf_moh_start(), and conf_moh_stop().

3008 {
3009  struct ast_bridge_channel *bridge_channel;
3010 /* XXX ASTERISK-21271 the case of a dissolved bridge while channel is suspended is not handled. */
3011 /* XXX ASTERISK-21271 suspend/unsuspend needs to be rethought. The caller must block until it has successfully suspended the channel for temporary control. */
3012 /* XXX ASTERISK-21271 external suspend/unsuspend needs to be eliminated. The channel may be playing a file at the time and stealing it then is not good. */
3013 
3014  ast_bridge_lock(bridge);
3015 
3016  if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
3017  ast_bridge_unlock(bridge);
3018  return -1;
3019  }
3020 
3021  bridge_channel_internal_suspend_nolock(bridge_channel);
3022 
3023  ast_bridge_unlock(bridge);
3024 
3025  return 0;
3026 }
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Structure that contains information regarding a channel in a bridge.
struct ast_bridge* ast_bridge_transfer_acquire_bridge ( struct ast_channel chan)

Acquire the channel's bridge for transfer purposes.

Since
13.21.0
Parameters
chanChannel involved in a transfer.
Returns
The bridge the channel is in or NULL if it either isn't in a bridge or should not be considered to be in a bridge.

Definition at line 4408 of file bridge.c.

References ao2_ref, AST_BRIDGE_FLAG_INVISIBLE, AST_BRIDGE_FLAG_MASQUERADE_ONLY, ast_channel_get_bridge(), and ast_bridge::feature_flags.

Referenced by ast_bridge_transfer_attended(), and ast_bridge_transfer_blind().

4409 {
4410  struct ast_bridge *bridge;
4411 
4412  ast_channel_lock(chan);
4413  bridge = ast_channel_get_bridge(chan);
4414  ast_channel_unlock(chan);
4415 
4416  if (bridge && ast_test_flag(&bridge->feature_flags,
4418  ao2_ref(bridge, -1);
4419  bridge = NULL;
4420  }
4421 
4422  return bridge;
4423 }
struct ast_flags feature_flags
Definition: bridge.h:369
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10534
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
Structure that contains information about a bridge.
Definition: bridge.h:349
enum ast_transfer_result ast_bridge_transfer_attended ( struct ast_channel to_transferee,
struct ast_channel to_transfer_target 
)

Attended transfer.

The two channels are both transferer channels. The first is the channel that is bridged to the transferee (or if unbridged, the 'first' call of the transfer). The second is the channel that is bridged to the transfer target (or if unbridged, the 'second' call of the transfer).

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
to_transfereeTransferer channel on initial call (presumably bridged to transferee)
to_transfer_targetTransferer channel on consultation call (presumably bridged to transfer target)
Returns
The success or failure of the attended transfer

Definition at line 4677 of file bridge.c.

References ao2_container_count(), ast_attended_transfer_message_add_app(), ast_attended_transfer_message_create(), ast_bridge_channel_write_playfile(), ast_bridge_channel_write_unhold(), AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY, AST_BRIDGE_FLAG_TRANSFER_PROHIBITED, ast_bridge_lock, ast_bridge_lock_both, ast_bridge_peers_nolock(), ast_bridge_publish_attended_transfer(), ast_bridge_remove(), ast_bridge_transfer_acquire_bridge(), AST_BRIDGE_TRANSFER_FAIL, AST_BRIDGE_TRANSFER_INVALID, AST_BRIDGE_TRANSFER_NOT_PERMITTED, AST_BRIDGE_TRANSFER_SUCCESS, ast_bridge_unlock, ast_channel_get_bridge_channel(), ast_softhangup(), AST_SOFTHANGUP_DEV, ast_strdupa, attended_transfer_bridge(), ast_bridge::feature_flags, lock, pbx_builtin_getvar_helper(), RAII_VAR, ast_attended_transfer_message::result, and SCOPED_LOCK.

4679 {
4680  RAII_VAR(struct ast_bridge *, to_transferee_bridge, NULL, ao2_cleanup);
4681  RAII_VAR(struct ast_bridge *, to_target_bridge, NULL, ao2_cleanup);
4682  RAII_VAR(struct ast_bridge_channel *, to_transferee_bridge_channel, NULL, ao2_cleanup);
4683  RAII_VAR(struct ast_bridge_channel *, to_target_bridge_channel, NULL, ao2_cleanup);
4684  RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
4685  RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
4686  RAII_VAR(struct ast_attended_transfer_message *, transfer_msg, NULL, ao2_cleanup);
4687  struct ast_bridge *the_bridge = NULL;
4688  struct ast_channel *chan_bridged;
4689  struct ast_channel *chan_unbridged;
4690  int transfer_prohibited;
4691  int do_bridge_transfer;
4692  enum ast_transfer_result res;
4693  const char *app = NULL;
4694  int hangup_target = 0;
4695 
4696  to_transferee_bridge = ast_bridge_transfer_acquire_bridge(to_transferee);
4697  to_target_bridge = ast_bridge_transfer_acquire_bridge(to_transfer_target);
4698 
4699  transfer_msg = ast_attended_transfer_message_create(1, to_transferee, to_transferee_bridge,
4700  to_transfer_target, to_target_bridge, NULL, NULL);
4701  if (!transfer_msg) {
4702  ast_log(LOG_ERROR, "Unable to create Stasis publication for attended transfer from %s\n",
4703  ast_channel_name(to_transferee));
4704  return AST_BRIDGE_TRANSFER_FAIL;
4705  }
4706 
4707  /* They can't both be unbridged, you silly goose! */
4708  if (!to_transferee_bridge && !to_target_bridge) {
4710  goto end;
4711  }
4712 
4713  ast_channel_lock(to_transferee);
4714  to_transferee_bridge_channel = ast_channel_get_bridge_channel(to_transferee);
4715  ast_channel_unlock(to_transferee);
4716 
4717  ast_channel_lock(to_transfer_target);
4718  to_target_bridge_channel = ast_channel_get_bridge_channel(to_transfer_target);
4719  ast_channel_unlock(to_transfer_target);
4720 
4721  if (to_transferee_bridge_channel) {
4722  /* Take off hold if they are on hold. */
4723  if (ast_bridge_channel_write_unhold(to_transferee_bridge_channel)) {
4724  ast_log(LOG_ERROR, "Transferee channel disappeared during transfer!\n");
4726  goto end;
4727  }
4728  }
4729 
4730  if (to_target_bridge_channel) {
4731  const char *target_complete_sound;
4732 
4733  /* Take off hold if they are on hold. */
4734  if (ast_bridge_channel_write_unhold(to_target_bridge_channel)) {
4735  ast_log(LOG_ERROR, "Target channel disappeared during transfer!\n");
4737  goto end;
4738  }
4739 
4740  /* Is there a courtesy sound to play to the target? */
4741  ast_channel_lock(to_transfer_target);
4742  target_complete_sound = pbx_builtin_getvar_helper(to_transfer_target,
4743  "ATTENDED_TRANSFER_COMPLETE_SOUND");
4744  if (!ast_strlen_zero(target_complete_sound)) {
4745  target_complete_sound = ast_strdupa(target_complete_sound);
4746  } else {
4747  target_complete_sound = NULL;
4748  }
4749  ast_channel_unlock(to_transfer_target);
4750  if (!target_complete_sound) {
4751  ast_channel_lock(to_transferee);
4752  target_complete_sound = pbx_builtin_getvar_helper(to_transferee,
4753  "ATTENDED_TRANSFER_COMPLETE_SOUND");
4754  if (!ast_strlen_zero(target_complete_sound)) {
4755  target_complete_sound = ast_strdupa(target_complete_sound);
4756  } else {
4757  target_complete_sound = NULL;
4758  }
4759  ast_channel_unlock(to_transferee);
4760  }
4761  if (target_complete_sound) {
4762  ast_bridge_channel_write_playfile(to_target_bridge_channel, NULL,
4763  target_complete_sound, NULL);
4764  }
4765  }
4766 
4767  /* Let's get the easy one out of the way first */
4768  if (to_transferee_bridge && to_target_bridge) {
4769 
4770  if (!to_transferee_bridge_channel || !to_target_bridge_channel) {
4772  goto end;
4773  }
4774 
4775  ast_bridge_lock_both(to_transferee_bridge, to_target_bridge);
4776  res = two_bridge_attended_transfer(to_transferee, to_transferee_bridge_channel,
4777  to_transfer_target, to_target_bridge_channel,
4778  to_transferee_bridge, to_target_bridge, transfer_msg);
4779  ast_bridge_unlock(to_transferee_bridge);
4780  ast_bridge_unlock(to_target_bridge);
4781 
4782  hangup_target = 1;
4783  goto end;
4784  }
4785 
4786  the_bridge = to_transferee_bridge ?: to_target_bridge;
4787  chan_bridged = to_transferee_bridge ? to_transferee : to_transfer_target;
4788  chan_unbridged = to_transferee_bridge ? to_transfer_target : to_transferee;
4789 
4790  /*
4791  * Race condition makes it possible for app to be NULL, so get the app prior to
4792  * transferring with a fallback of "unknown".
4793  */
4794  app = ast_strdupa(ast_channel_appl(chan_unbridged) ?: "unknown");
4795 
4796  {
4797  int chan_count;
4799 
4800  channels = ast_bridge_peers_nolock(the_bridge);
4801  if (!channels) {
4803  goto end;
4804  }
4805  chan_count = ao2_container_count(channels);
4806  if (chan_count <= 1) {
4808  goto end;
4809  }
4810  transfer_prohibited = ast_test_flag(&the_bridge->feature_flags,
4812  do_bridge_transfer = ast_test_flag(&the_bridge->feature_flags,
4814  chan_count > 2;
4815  }
4816 
4817  if (transfer_prohibited) {
4819  goto end;
4820  }
4821 
4822  set_transfer_variables_all(to_transferee, channels, 1);
4823 
4824  if (do_bridge_transfer) {
4825  /*
4826  * Hang up the target if it was bridged. Note, if it is not bridged
4827  * it is hung up during the masquerade.
4828  */
4829  hangup_target = chan_bridged == to_transfer_target;
4830  ast_bridge_lock(the_bridge);
4831  res = attended_transfer_bridge(chan_bridged, chan_unbridged, the_bridge, NULL, transfer_msg);
4832  ast_bridge_unlock(the_bridge);
4833  goto end;
4834  }
4835 
4836  transferee = get_transferee(channels, chan_bridged);
4837  if (!transferee) {
4839  goto end;
4840  }
4841 
4842  if (bridge_channel_internal_queue_attended_transfer(transferee, chan_unbridged)) {
4844  goto end;
4845  }
4846 
4847  ast_bridge_remove(the_bridge, chan_bridged);
4848 
4849  ast_attended_transfer_message_add_app(transfer_msg, app, NULL);
4851 
4852 end:
4853  if ((res == AST_BRIDGE_TRANSFER_SUCCESS && hangup_target) || res == AST_BRIDGE_TRANSFER_FAIL) {
4854  ast_softhangup(to_transfer_target, AST_SOFTHANGUP_DEV);
4855  }
4856 
4857  transfer_msg->result = res;
4859  return res;
4860 }
Main Channel structure associated with a channel.
#define ast_bridge_lock_both(bridge1, bridge2)
Lock two bridges.
Definition: bridge.h:488
struct ast_flags feature_flags
Definition: bridge.h:369
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ast_bridge * ast_bridge_transfer_acquire_bridge(struct ast_channel *chan)
Acquire the channel's bridge for transfer purposes.
Definition: bridge.c:4408
int ast_attended_transfer_message_add_app(struct ast_attended_transfer_message *transfer_msg, const char *app, struct ast_channel *replace_channel)
Add details for an attended transfer to an application.
Message representing attended transfer.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2471
void ast_bridge_publish_attended_transfer(struct ast_attended_transfer_message *transfer_msg)
Publish an attended transfer.
ast_transfer_result
Definition: bridge.h:1098
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_attended_transfer_message * ast_attended_transfer_message_create(int is_external, struct ast_channel *to_transferee, struct ast_bridge *transferee_bridge, struct ast_channel *to_transfer_target, struct ast_bridge *target_bridge, struct ast_channel *transferee, struct ast_channel *transfer_target)
Create an Attended transfer message to be published.
ast_mutex_t lock
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:583
static enum ast_transfer_result attended_transfer_bridge(struct ast_channel *chan1, struct ast_channel *chan2, struct ast_bridge *bridge1, struct ast_bridge *bridge2, struct ast_attended_transfer_message *transfer_msg)
Perform an attended transfer of a bridge.
Definition: bridge.c:4221
Structure that contains information about a bridge.
Definition: bridge.h:349
int ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
Write a bridge action play file frame into the bridge.
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
struct ao2_container * ast_bridge_peers_nolock(struct ast_bridge *bridge)
Get a container of all channels in the bridge.
Definition: bridge.c:4018
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition: channel.c:10582
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
struct ast_bridge_channels_list channels
Definition: bridge.h:363
Structure that contains information regarding a channel in a bridge.
Generic container type.
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
Remove a channel from a bridge.
Definition: bridge.c:1951
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
Write an unhold frame into the bridge.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941
enum ast_transfer_result ast_bridge_transfer_blind ( int  is_external,
struct ast_channel transferer,
const char *  exten,
const char *  context,
transfer_channel_cb  new_channel_cb,
void *  user_data 
)

Blind transfer target to the extension and context provided.

The channel given is bridged to one or multiple channels. Depending on the bridge and the number of participants, the entire bridge could be transferred to the given destination, or a single channel may be redirected.

Callers may also provide a callback to be called on the channel that will be running dialplan. The user data passed into ast_bridge_transfer_blind will be given as the argument to the callback to be interpreted as desired. This callback is guaranteed to be called in the same thread as ast_bridge_transfer_blind() and before ast_bridge_transfer_blind() returns.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
is_externalIndicates that transfer was initiated externally
transfererThe channel performing the blind transfer
extenThe dialplan extension to send the call to
contextThe dialplan context to send the call to
new_channel_cbA callback to be called on the channel that will be executing dialplan
user_dataArgument for new_channel_cb
Returns
The success or failure result of the blind transfer

Definition at line 4425 of file bridge.c.

References ao2_container_count(), ast_blind_transfer_message_create(), ast_bridge_channel_write_unhold(), AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY, AST_BRIDGE_FLAG_TRANSFER_PROHIBITED, ast_bridge_lock, ast_bridge_peer(), ast_bridge_peers_nolock(), ast_bridge_publish_blind_transfer(), ast_bridge_remove(), ast_bridge_snapshot_create(), ast_bridge_transfer_acquire_bridge(), AST_BRIDGE_TRANSFER_FAIL, AST_BRIDGE_TRANSFER_INVALID, AST_BRIDGE_TRANSFER_NOT_PERMITTED, AST_BRIDGE_TRANSFER_SUCCESS, ast_bridge_unlock, ast_channel_cleanup, ast_channel_get_bridge_channel(), ast_channel_snapshot_get_latest(), ast_blind_transfer_message::bridge, transfer_channel_data::completed, ast_bridge::feature_flags, lock, RAII_VAR, ast_blind_transfer_message::result, SCOPED_LOCK, and ast_blind_transfer_message::transferee.

Referenced by feature_blind_transfer().

4428 {
4429  RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
4430  RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
4431  RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
4432  RAII_VAR(struct ast_channel *, transferee, NULL, ast_channel_cleanup);
4433  RAII_VAR(struct transfer_channel_data *, user_data_wrapper, NULL, ao2_cleanup);
4434  RAII_VAR(struct ast_blind_transfer_message *, transfer_message, NULL, ao2_cleanup);
4435  int do_bridge_transfer;
4436  int transfer_prohibited;
4437  enum ast_transfer_result transfer_result;
4438 
4439  transfer_message = ast_blind_transfer_message_create(is_external, transferer, exten, context);
4440  if (!transfer_message) {
4441  /* Out of memory. Not even possible to publish a Stasis message about the
4442  * failure
4443  */
4444  ast_log(LOG_ERROR, "Unable to allocate memory for blind transfer publication from %s\n",
4445  ast_channel_name(transferer));
4446  return AST_BRIDGE_TRANSFER_FAIL;
4447  }
4448 
4450  if (!bridge) {
4451  transfer_result = AST_BRIDGE_TRANSFER_INVALID;
4452  goto publish;
4453  }
4454 
4456  transfer_message->bridge = ast_bridge_snapshot_create(bridge);
4458  if (!transfer_message->bridge) {
4459  transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4460  goto publish;
4461  }
4462 
4463  transferee = ast_bridge_peer(bridge, transferer);
4464  if (transferee) {
4465  transfer_message->transferee = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transferee));
4466  if (!transfer_message->transferee) {
4467  transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4468  goto publish;
4469  }
4470  }
4471 
4472  ast_channel_lock(transferer);
4474  ast_channel_unlock(transferer);
4475  if (!bridge_channel) {
4476  transfer_result = AST_BRIDGE_TRANSFER_INVALID;
4477  goto publish;
4478  }
4479 
4480  user_data_wrapper = ao2_alloc(sizeof(*user_data_wrapper), NULL);
4481  if (!user_data_wrapper) {
4482  transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4483  goto publish;
4484  }
4485 
4486  user_data_wrapper->data = user_data;
4487 
4488  /* Take off hold if they are on hold. */
4490 
4491  transfer_result = try_parking(transferer, context, exten, new_channel_cb, user_data_wrapper);
4492  if (transfer_result == AST_BRIDGE_TRANSFER_SUCCESS) {
4493  goto publish;
4494  }
4495 
4496  /* Since parking didn't take control of the user_data_wrapper, we are just going to raise the completed flag now. */
4497  user_data_wrapper->completed = 1;
4498 
4499  {
4501 
4502  channels = ast_bridge_peers_nolock(bridge);
4503  if (!channels) {
4504  transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4505  goto publish;
4506  }
4507  if (ao2_container_count(channels) <= 1) {
4508  transfer_result = AST_BRIDGE_TRANSFER_INVALID;
4509  goto publish;
4510  }
4511  transfer_prohibited = ast_test_flag(&bridge->feature_flags,
4513  do_bridge_transfer = ast_test_flag(&bridge->feature_flags,
4515  ao2_container_count(channels) > 2;
4516  }
4517 
4518  if (transfer_prohibited) {
4519  transfer_result = AST_BRIDGE_TRANSFER_NOT_PERMITTED;
4520  goto publish;
4521  }
4522 
4523  set_transfer_variables_all(transferer, channels, 0);
4524 
4525  if (do_bridge_transfer) {
4526  transfer_result = blind_transfer_bridge(is_external, transferer, bridge,
4527  exten, context, transferee, new_channel_cb, user_data_wrapper, transfer_message);
4528  goto publish;
4529  }
4530 
4531  /* Reaching this portion means that we're dealing with a two-party bridge */
4532 
4533  if (!transferee) {
4534  transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4535  goto publish;
4536  }
4537 
4538  if (bridge_channel_internal_queue_blind_transfer(transferee, exten, context,
4539  new_channel_cb, user_data_wrapper)) {
4540  transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4541  goto publish;
4542  }
4543 
4544  ast_bridge_remove(bridge, transferer);
4545  transfer_result = AST_BRIDGE_TRANSFER_SUCCESS;
4546 
4547 publish:
4548  transfer_message->result = transfer_result;
4549  ast_bridge_publish_blind_transfer(transfer_message);
4550  return transfer_result;
4551 }
struct ast_blind_transfer_message * ast_blind_transfer_message_create(int is_external, struct ast_channel *transferer, const char *exten, const char *context)
Create a blind transfer message to be published.
Main Channel structure associated with a channel.
struct ast_flags feature_flags
Definition: bridge.h:369
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ast_bridge * ast_bridge_transfer_acquire_bridge(struct ast_channel *chan)
Acquire the channel's bridge for transfer purposes.
Definition: bridge.c:4408
Message published during a blind transfer.
char context[AST_MAX_CONTEXT]
void ast_bridge_publish_blind_transfer(struct ast_blind_transfer_message *transfer_message)
Publish a blind transfer event.
ast_transfer_result
Definition: bridge.h:1098
struct ast_bridge_channel * bridge_channel
ast_mutex_t lock
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2969
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:583
Structure that contains information about a bridge.
Definition: bridge.h:349
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: bridge.c:4075
struct ast_bridge * bridge
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
struct ast_bridge_snapshot * ast_bridge_snapshot_create(struct ast_bridge *bridge)
Generate a snapshot of the bridge state. This is an ao2 object, so ao2_cleanup() to deallocate...
struct ao2_container * ast_bridge_peers_nolock(struct ast_bridge *bridge)
Get a container of all channels in the bridge.
Definition: bridge.c:4018
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition: channel.c:10582
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Structure that contains information regarding a channel in a bridge.
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object...
AO2 object that wraps data for transfer_channel_cb.
Definition: bridge.h:1119
Generic container type.
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
Remove a channel from a bridge.
Definition: bridge.c:1951
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
Write an unhold frame into the bridge.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941
char exten[AST_MAX_EXTENSION]
int ast_bridge_unreal_optimize_out ( struct ast_channel chan,
struct ast_channel peer,
struct ast_unreal_pvt pvt 
)

Check and optimize out the unreal channels between bridges.

Since
12.0.0
Parameters
chanUnreal channel writing a frame into the channel driver.
peerOther unreal channel in the pair.
pvtPrivate data provided by an implementation of the unreal driver that contains the callbacks that should be called when optimization begins/ends
Note
It is assumed that chan is already locked.
Return values
0if unreal channels were not optimized out.
non-zeroif unreal channels were optimized out.

Definition at line 2920 of file bridge.c.

References ast_bridge_channel_unlock, and ast_bridge_unlock.

2921 {
2922  struct ast_bridge *chan_bridge;
2923  struct ast_bridge *peer_bridge;
2924  struct ast_bridge_channel *chan_bridge_channel;
2925  struct ast_bridge_channel *peer_bridge_channel;
2926  int res = 0;
2927 
2928  chan_bridge = optimize_lock_chan_stack(chan);
2929  if (!chan_bridge) {
2930  return res;
2931  }
2932  chan_bridge_channel = ast_channel_internal_bridge_channel(chan);
2933 
2934  peer_bridge = optimize_lock_peer_stack(peer);
2935  if (peer_bridge) {
2936  peer_bridge_channel = ast_channel_internal_bridge_channel(peer);
2937 
2938  res = try_swap_optimize_out(chan_bridge, chan_bridge_channel,
2939  peer_bridge, peer_bridge_channel, pvt);
2940  if (!res) {
2941  res = try_merge_optimize_out(chan_bridge, chan_bridge_channel,
2942  peer_bridge, peer_bridge_channel, pvt);
2943  } else if (0 < res) {
2944  res = 0;
2945  }
2946 
2947  /* Release peer locks. */
2948  ast_bridge_unlock(peer_bridge);
2949  ast_bridge_channel_unlock(peer_bridge_channel);
2950  ast_channel_unlock(peer);
2951  }
2952 
2953  /* Release chan locks. */
2954  ast_bridge_unlock(chan_bridge);
2955  ast_bridge_channel_unlock(chan_bridge_channel);
2956 
2957  return res;
2958 }
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
Structure that contains information about a bridge.
Definition: bridge.h:349
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
Structure that contains information regarding a channel in a bridge.
int ast_bridge_unsuspend ( struct ast_bridge bridge,
struct ast_channel chan 
)

Unsuspend a channel from a bridge.

Parameters
bridgeBridge to unsuspend the channel from
chanChannel to unsuspend
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_unsuspend(bridge, chan);

This unsuspends the channel pointed to by chan from the bridge pointed to by bridge. The bridge will go back to handling the channel once this function returns.

Note
You must not mess with the channel once this function returns. Doing so may result in bad things happening.

Definition at line 3028 of file bridge.c.

References ast_bridge_lock, and ast_bridge_unlock.

Referenced by conf_moh_start(), and conf_moh_stop().

3029 {
3030  struct ast_bridge_channel *bridge_channel;
3031 /* XXX ASTERISK-21271 the case of a dissolved bridge while channel is suspended is not handled. */
3032 
3033  ast_bridge_lock(bridge);
3034 
3035  if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
3036  ast_bridge_unlock(bridge);
3037  return -1;
3038  }
3039 
3040  bridge_channel_internal_unsuspend_nolock(bridge_channel);
3041 
3042  ast_bridge_unlock(bridge);
3043 
3044  return 0;
3045 }
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Structure that contains information regarding a channel in a bridge.
void ast_bridge_vars_set ( struct ast_channel chan,
const char *  name,
const char *  pvtid 
)

Sets BRIDGECHANNEL and BRIDGEPVTCALLID for a channel.

Precondition
chan must be locked before calling
Parameters
chanchannel name of the bridged peer
name
pvtidPrivate CallID of the bridged peer

Definition at line 1212 of file bridge.c.

References ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), and pbx_builtin_setvar_helper().

Referenced by ast_bridge_channel_leave_bridge_nolock().

1213 {
1215  pbx_builtin_setvar_helper(chan, "BRIDGEPEER", name);
1216  pbx_builtin_setvar_helper(chan, "BRIDGEPVTCALLID", pvtid);
1218 }
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
const char* ast_bridge_video_mode_to_string ( enum ast_bridge_video_mode_type  video_mode)

Converts an enum representation of a bridge video mode to string.

Parameters
video_modeThe video mode
Returns
A string representation of video_mode

Definition at line 3951 of file bridge.c.

References AST_BRIDGE_VIDEO_MODE_NONE, AST_BRIDGE_VIDEO_MODE_SFU, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, and AST_BRIDGE_VIDEO_MODE_TALKER_SRC.

Referenced by ast_bridge_snapshot_to_json(), and ast_manager_build_bridge_state_string_prefix().

3952 {
3953  switch (video_mode) {
3955  return "talker";
3957  return "single";
3959  return "sfu";
3961  default:
3962  return "none";
3963  }
3964 }
struct ao2_container* ast_bridges ( void  )

Returns the global bridges container.

Since
17.0
Returns
a pointer to the bridges container success
Return values
NULLon failure
Note
You must use
ao2_ref(<container>, -1) 
when done with it
Warning
You must not attempt to modify the container returned.

Definition at line 174 of file bridge.c.

References ao2_bump.

Referenced by ast_ari_bridges_list().

175 {
176  return ao2_bump(bridges);
177 }
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
static struct ao2_container * bridges
Definition: bridge.c:123
enum ast_bridge_optimization ast_bridges_allow_optimization ( struct ast_bridge chan_bridge,
struct ast_bridge peer_bridge 
)

Determine if bridges allow for optimization to occur betweem them.

Since
12.0.0
Parameters
chan_bridgeFirst bridge being tested
peer_bridgeSecond bridge being tested

This determines if two bridges allow for unreal channel optimization to occur between them. The function does not require for unreal channels to already be in the bridges when called.

Note
It is assumed that both bridges are locked prior to calling this function
A return other than AST_BRIDGE_OPTIMIZE_PROHIBITED does not guarantee that an optimization attempt will succeed. However, a return of AST_BRIDGE_OPTIMIZE_PROHIBITED guarantees that an optimization attempt will never succeed.
Returns
Optimization allowability for the bridges

Definition at line 2960 of file bridge.c.

References AST_BRIDGE_OPTIMIZE_MERGE_TO_CHAN_BRIDGE, AST_BRIDGE_OPTIMIZE_MERGE_TO_PEER_BRIDGE, AST_BRIDGE_OPTIMIZE_PROHIBITED, AST_BRIDGE_OPTIMIZE_SWAP_TO_CHAN_BRIDGE, AST_BRIDGE_OPTIMIZE_SWAP_TO_PEER_BRIDGE, merge_direction::dest, MERGE_ALLOWED, SWAP_PROHIBITED, SWAP_TO_CHAN_BRIDGE, and SWAP_TO_PEER_BRIDGE.

2962 {
2963  struct merge_direction merge;
2964 
2965  if (!bridge_allows_optimization(chan_bridge) || !bridge_allows_optimization(peer_bridge)) {
2967  }
2968 
2969  switch (bridges_allow_swap_optimization(chan_bridge, peer_bridge)) {
2970  case SWAP_TO_CHAN_BRIDGE:
2972  case SWAP_TO_PEER_BRIDGE:
2974  case SWAP_PROHIBITED:
2975  default:
2976  break;
2977  }
2978 
2979  /* Two channels will be kicked from the bridges, the unreal;1 and unreal;2 channels */
2980  if (bridges_allow_merge_optimization(chan_bridge, peer_bridge, 2, &merge) != MERGE_ALLOWED) {
2982  }
2983 
2984  if (merge.dest == chan_bridge) {
2986  } else {
2988  }
2989 }
void ast_brige_set_remb_behavior ( struct ast_bridge bridge,
enum ast_bridge_video_sfu_remb_behavior  behavior 
)

Set the REMB report generation behavior on a bridge.

Parameters
bridgeBridge to set the REMB behavior on
behaviorHow REMB reports are generated
Note
This can only be called when the bridge has been set to the SFU video mode.

Definition at line 3798 of file bridge.c.

References ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, ast_bridge_video_sfu_data::remb_behavior, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by join_conference_bridge().

3799 {
3800  ast_assert(bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU);
3801 
3802  ast_bridge_lock(bridge);
3803  bridge->softmix.video_mode.mode_data.sfu_data.remb_behavior = behavior;
3804  ast_bridge_unlock(bridge);
3805 }
struct ast_bridge_video_mode video_mode
Definition: bridge.h:279
struct ast_bridge_softmix softmix
Definition: bridge.h:367
enum ast_bridge_video_sfu_remb_behavior remb_behavior
Definition: bridge.h:153
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470