Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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"
Include dependency graph for bridge.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. More...
 
#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...
 
#define BRIDGE_PRINTF_SPEC   "%s(%s)(%p)"
 
#define BRIDGE_PRINTF_VARS(bridge)   S_OR((bridge)->uniqueid, "<unknown>"), S_OR((bridge)->name, "<unknown>"), (bridge)
 

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

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

◆ ast_bridge_lock

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

Lock the bridge.

Parameters
bridgeBridge to lock

Definition at line 474 of file bridge.h.

◆ ast_bridge_lock_both

#define ast_bridge_lock_both (   bridge1,
  bridge2 
)

Lock two bridges.

Definition at line 492 of file bridge.h.

◆ ast_bridge_trylock

#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 463 of file bridge.h.

◆ ast_bridge_unlock

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

Unlock the bridge.

Parameters
bridgeBridge to unlock

Definition at line 485 of file bridge.h.

◆ BRIDGE_PRINTF_SPEC

#define BRIDGE_PRINTF_SPEC   "%s(%s)(%p)"

Definition at line 79 of file bridge.h.

◆ BRIDGE_PRINTF_VARS

#define BRIDGE_PRINTF_VARS (   bridge)    S_OR((bridge)->uniqueid, "<unknown>"), S_OR((bridge)->name, "<unknown>"), (bridge)

Definition at line 80 of file bridge.h.

Typedef Documentation

◆ ast_bridge_destructor_fn

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

Destroy the bridge.

Parameters
selfBridge to operate upon.

Definition at line 180 of file bridge.h.

◆ ast_bridge_dissolving_fn

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 193 of file bridge.h.

◆ ast_bridge_merge_priority_fn

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 253 of file bridge.h.

◆ ast_bridge_notify_masquerade_fn

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 242 of file bridge.h.

◆ ast_bridge_pull_channel_fn

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 228 of file bridge.h.

◆ ast_bridge_push_channel_fn

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 213 of file bridge.h.

◆ transfer_channel_cb

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 1147 of file bridge.h.

Enumeration Type Documentation

◆ ast_bridge_capability

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 88 of file bridge.h.

88 {
89 /*! Bridge technology can service calls on hold. */
91 /*! Bridge waits for channel to answer. Passes early media. (XXX Not supported yet) */
93 /*! Bridge is capable of natively bridging two channels. (Smart bridge only) */
95 /*! Bridge is capable of mixing at most two channels. (Smart bridgeable) */
97 /*! Bridge is capable of mixing an arbitrary number of channels. (Smart bridgeable) */
99};
@ AST_BRIDGE_CAPABILITY_EARLY
Definition: bridge.h:92
@ AST_BRIDGE_CAPABILITY_MULTIMIX
Definition: bridge.h:98
@ AST_BRIDGE_CAPABILITY_NATIVE
Definition: bridge.h:94
@ AST_BRIDGE_CAPABILITY_1TO1MIX
Definition: bridge.h:96
@ AST_BRIDGE_CAPABILITY_HOLDING
Definition: bridge.h:90

◆ ast_bridge_impart_flags

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 588 of file bridge.h.

588 {
589 /*! Field describing what the caller can do with the channel after it is imparted. */
591 /*! The caller wants to reclaim the channel using ast_bridge_depart(). */
593 /*! The caller is passing channel control entirely to the bridging system. */
595 /*! The initial bridge join does not cause a COLP exchange. */
597};
@ AST_BRIDGE_IMPART_CHAN_DEPARTABLE
Definition: bridge.h:592
@ AST_BRIDGE_IMPART_CHAN_MASK
Definition: bridge.h:590
@ AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP
Definition: bridge.h:596
@ AST_BRIDGE_IMPART_CHAN_INDEPENDENT
Definition: bridge.h:594

◆ ast_bridge_join_flags

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 537 of file bridge.h.

537 {
538 /*! The bridge reference is being passed by the caller. */
540 /*! The initial bridge join does not cause a COLP exchange. */
542};
@ AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP
Definition: bridge.h:541
@ AST_BRIDGE_JOIN_PASS_REFERENCE
Definition: bridge.h:539

◆ ast_bridge_optimization

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 878 of file bridge.h.

878 {
879 /*! Optimization would swap peer into the chan_bridge */
881 /*! Optimization would swap chan into the peer_bridge */
883 /*! Optimization would merge peer_bridge into chan_bridge */
885 /*! Optimization would merge chan_bridge into peer_bridge */
887 /*! Optimization is not permitted on one or both bridges */
889};
@ AST_BRIDGE_OPTIMIZE_PROHIBITED
Definition: bridge.h:888
@ AST_BRIDGE_OPTIMIZE_MERGE_TO_CHAN_BRIDGE
Definition: bridge.h:884
@ AST_BRIDGE_OPTIMIZE_SWAP_TO_PEER_BRIDGE
Definition: bridge.h:882
@ AST_BRIDGE_OPTIMIZE_MERGE_TO_PEER_BRIDGE
Definition: bridge.h:886
@ AST_BRIDGE_OPTIMIZE_SWAP_TO_CHAN_BRIDGE
Definition: bridge.h:880

◆ ast_bridge_video_mode_type

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 102 of file bridge.h.

102 {
103 /*! Video is not allowed in the bridge */
105 /*! A single user is picked as the only distributed of video across the bridge */
107 /*! A single user's video feed is distributed to all bridge channels, but
108 * that feed is automatically picked based on who is talking the most. */
110 /*! Operate as a selective forwarding unit. Video from each participant is
111 * cloned to a dedicated stream on a subset of the remaining participants.
112 */
114};
@ AST_BRIDGE_VIDEO_MODE_SINGLE_SRC
Definition: bridge.h:106
@ AST_BRIDGE_VIDEO_MODE_TALKER_SRC
Definition: bridge.h:109
@ AST_BRIDGE_VIDEO_MODE_NONE
Definition: bridge.h:104
@ AST_BRIDGE_VIDEO_MODE_SFU
Definition: bridge.h:113

◆ ast_bridge_video_sfu_remb_behavior

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 135 of file bridge.h.

135 {
136 /*! The average of all reports is sent to the sender */
138 /*! The lowest reported bitrate is forwarded to the sender */
140 /*! The highest reported bitrate is forwarded to the sender */
142 /*! The average of all reports WITHIN the bridge is sent to each sender */
144 /*! The lowest reported bitrate from all channels in the bridge is forwarded to each sender */
146 /*! The highest reported bitrate from all channels in the bridge is forwarded to each sender */
148 /*! Force the REMB estimated bitrate to a specified value */
150};
@ AST_BRIDGE_VIDEO_SFU_REMB_LOWEST
Definition: bridge.h:139
@ AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL
Definition: bridge.h:147
@ AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE
Definition: bridge.h:137
@ AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST
Definition: bridge.h:141
@ AST_BRIDGE_VIDEO_SFU_REMB_AVERAGE_ALL
Definition: bridge.h:143
@ AST_BRIDGE_VIDEO_SFU_REMB_FORCE
Definition: bridge.h:149
@ AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL
Definition: bridge.h:145

◆ ast_transfer_result

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 1102 of file bridge.h.

1102 {
1103 /*! The transfer completed successfully */
1105 /*! A bridge involved does not permit transferring */
1107 /*! The current bridge setup makes transferring an invalid operation */
1109 /*! The transfer operation failed for a miscellaneous reason */
1111};
@ AST_BRIDGE_TRANSFER_NOT_PERMITTED
Definition: bridge.h:1106
@ AST_BRIDGE_TRANSFER_SUCCESS
Definition: bridge.h:1104
@ AST_BRIDGE_TRANSFER_INVALID
Definition: bridge.h:1108
@ AST_BRIDGE_TRANSFER_FAIL
Definition: bridge.h:1110

◆ ast_transfer_type

Enumerator
AST_BRIDGE_TRANSFER_SINGLE_PARTY 

Transfer of a single party

AST_BRIDGE_TRANSFER_MULTI_PARTY 

Transfer of multiple parties

Definition at line 1113 of file bridge.h.

1113 {
1114 /*! Transfer of a single party */
1116 /*! Transfer of multiple parties */
1118};
@ AST_BRIDGE_TRANSFER_SINGLE_PARTY
Definition: bridge.h:1115
@ AST_BRIDGE_TRANSFER_MULTI_PARTY
Definition: bridge.h:1117

Function Documentation

◆ _ast_bridge_lock()

static void _ast_bridge_lock ( struct ast_bridge bridge,
const char *  file,
const char *  function,
int  line,
const char *  var 
)
inlinestatic

Definition at line 475 of file bridge.h.

476{
477 __ao2_lock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var);
478}
#define var
Definition: ast_expr2f.c:605
@ AO2_LOCK_REQ_MUTEX
Definition: astobj2.h:702
int __ao2_lock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var)
Lock an object.
Definition: astobj2.c:222

References __ao2_lock(), AO2_LOCK_REQ_MUTEX, make_ari_stubs::file, and var.

◆ _ast_bridge_trylock()

static int _ast_bridge_trylock ( struct ast_bridge bridge,
const char *  file,
const char *  function,
int  line,
const char *  var 
)
inlinestatic

Definition at line 464 of file bridge.h.

465{
466 return __ao2_trylock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var);
467}
int __ao2_trylock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var)
Try locking– (don't block if fail)
Definition: astobj2.c:342

References __ao2_trylock(), AO2_LOCK_REQ_MUTEX, make_ari_stubs::file, and var.

◆ _ast_bridge_unlock()

static void _ast_bridge_unlock ( struct ast_bridge bridge,
const char *  file,
const char *  function,
int  line,
const char *  var 
)
inlinestatic

Definition at line 486 of file bridge.h.

487{
488 __ao2_unlock(bridge, file, function, line, var);
489}
int __ao2_unlock(void *a, const char *file, const char *func, int line, const char *var)
Unlock an object.
Definition: astobj2.c:288

References __ao2_unlock(), make_ari_stubs::file, and var.

◆ ast_bridge_base_new()

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:

struct ast_bridge *bridge;
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.
Definition: bridge.c:999
@ AST_BRIDGE_FLAG_DISSOLVE_HANGUP
Structure that contains information about a bridge.
Definition: bridge.h:353

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

Definition at line 999 of file bridge.c.

1000{
1001 void *bridge;
1002
1003 bridge = bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_base_v_table);
1004 bridge = bridge_base_init(bridge, capabilities, flags, creator, name, id);
1005 bridge = bridge_register(bridge);
1006 return bridge;
1007}
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
Definition: bridge.c:988
struct ast_bridge * bridge_register(struct ast_bridge *bridge)
Register the new bridge with the system.
Definition: bridge.c:713
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:783
struct ast_bridge * bridge_alloc(size_t size, const struct ast_bridge_methods *v_table)
Definition: bridge.c:747
static const char name[]
Definition: format_mp3.c:68

References ast_bridge_base_v_table, bridge_alloc(), bridge_base_init(), bridge_register(), ast_bridge::creator, and name.

Referenced by AST_TEST_DEFINE(), get_wait_bridge_wrapper(), and join_conference_bridge().

◆ ast_bridge_depart()

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:

int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
Definition: bridge.c:1975

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 1975 of file bridge.c.

1976{
1977 struct ast_bridge_channel *bridge_channel;
1978 int departable;
1979 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
1980
1982 bridge_channel = ast_channel_internal_bridge_channel(chan);
1983 departable = bridge_channel && bridge_channel->depart_wait;
1985 if (!departable) {
1986 ast_log(LOG_ERROR, "Channel %s cannot be departed.\n",
1988 /*
1989 * Should never happen. It likely means that
1990 * ast_bridge_depart() is called by two threads for the same
1991 * channel, the channel was never imparted to be departed, or it
1992 * has already been departed.
1993 */
1994 ast_assert(0);
1995 return -1;
1996 }
1997
1998 /*
1999 * We are claiming the bridge_channel reference held by
2000 * bridge_channel_depart_thread().
2001 */
2002
2003 ast_bridge_channel_leave_bridge(bridge_channel,
2005
2006 /* Wait for the depart thread to die */
2007 ast_debug(1, "Waiting for %p(%s) bridge thread to die.\n",
2008 bridge_channel, ast_channel_name(bridge_channel->chan));
2009 pthread_join(bridge_channel->thread, NULL);
2010
2014
2015 /* We can get rid of the bridge_channel after the depart thread has died. */
2016 ao2_ref(bridge_channel, -1);
2017 return 0;
2018}
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
@ BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE
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_CAUSE_NORMAL_CLEARING
Definition: causes.h:106
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
#define ast_channel_lock(chan)
Definition: channel.h:2970
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2971
#define SCOPE_TRACE(__level,...)
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_ERROR
#define NULL
Definition: resample.c:96
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
unsigned int depart_wait
#define ast_assert(a)
Definition: utils.h:739

References ao2_ref, ast_assert, ast_bridge_channel_leave_bridge(), AST_CAUSE_NORMAL_CLEARING, ast_channel_internal_bridge_channel(), ast_channel_internal_bridge_channel_set(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_debug, ast_log, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, ast_bridge_channel::chan, ast_bridge_channel::depart_wait, LOG_ERROR, NULL, SCOPE_TRACE, and ast_bridge_channel::thread.

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

◆ ast_bridge_destroy()

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:

int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
Definition: bridge.c:1009

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 1009 of file bridge.c.

1010{
1011 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": destroying. current refcount: %d\n",
1012 BRIDGE_PRINTF_VARS(bridge), ao2_ref(bridge, 0));
1013 ast_bridge_lock(bridge);
1014 bridge_dissolve(bridge, cause);
1015 ast_bridge_unlock(bridge);
1016
1017 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": unreffing. current refcount: %d\n",
1018 BRIDGE_PRINTF_VARS(bridge), ao2_ref(bridge, 0));
1019
1020 ao2_ref(bridge, -1);
1021
1022 return 0;
1023}
void bridge_dissolve(struct ast_bridge *bridge, int cause)
Definition: bridge.c:326
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:485
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:474
#define BRIDGE_PRINTF_VARS(bridge)
Definition: bridge.h:80
#define BRIDGE_PRINTF_SPEC
Definition: bridge.h:79

References ao2_ref, ast_bridge_lock, ast_bridge_unlock, ast_debug, bridge_dissolve(), BRIDGE_PRINTF_SPEC, BRIDGE_PRINTF_VARS, and ast_bridge::cause.

Referenced by action_bridge(), agent_connect_caller(), agent_logout(), agent_pvt_destructor(), agent_request_exec(), agent_run(), ast_bridge_call_with_flags(), attended_transfer_properties_shutdown(), bridge_base_init(), bridge_create_common(), bridge_exec(), bridge_register(), caller_abort_agent(), destroy_conference_bridge(), fail_enter(), manager_bridge_destroy(), parked_call_app_exec(), parking_lot_destructor(), safe_bridge_destroy(), stasis_app_bridge_destroy(), stasis_app_control_shutdown(), unload_module(), wait_bridge_wrapper_alloc(), and wait_bridge_wrapper_destructor().

◆ ast_bridge_features_remove()

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 3570 of file bridge.c.

3571{
3572 hooks_remove_container(features->dtmf_hooks, remove_flags);
3573 hooks_remove_container(features->other_hooks, remove_flags);
3574 hooks_remove_heap(features->interval_hooks, remove_flags);
3575}
static void hooks_remove_heap(struct ast_heap *hooks, enum ast_bridge_hook_remove_flags remove_flags)
Definition: bridge.c:3548
static void hooks_remove_container(struct ao2_container *hooks, enum ast_bridge_hook_remove_flags remove_flags)
Definition: bridge.c:3534
struct ao2_container * other_hooks
struct ao2_container * dtmf_hooks
struct ast_heap * interval_hooks

References ast_bridge_features::dtmf_hooks, hooks_remove_container(), hooks_remove_heap(), ast_bridge_features::interval_hooks, ast_bridge_features::other_hooks, and ast_bridge_hook::remove_flags.

Referenced by bridge_base_pull(), bridge_channel_internal_join(), bridge_do_merge(), bridge_do_move(), and remove_hooks_on_personality_change().

◆ ast_bridge_find_by_id()

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 5081 of file bridge.c.

5082{
5083 return ao2_find(bridges, bridge_id, OBJ_SEARCH_KEY);
5084}
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
static struct ao2_container * bridges
Definition: bridge.c:132

References ao2_find, bridges, and OBJ_SEARCH_KEY.

Referenced by ast_bridge_get_snapshot_by_uniqueid(), bridge_register(), complete_bridge_participant(), handle_bridge_kick_channel(), manager_bridge_destroy(), and manager_bridge_kick().

◆ ast_bridge_impart()

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:

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)
Definition: bridge.c:1947

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 1947 of file bridge.c.

1952{
1954 .done = 0,
1955 };
1956 int res;
1957 SCOPE_TRACE(1, "%s Bridge: %s\n", ast_channel_name(chan), bridge->uniqueid);
1958
1959 ast_mutex_init(&cond.lock);
1960 ast_cond_init(&cond.cond, NULL);
1961
1962 res = bridge_impart_internal(bridge, chan, swap, features, flags, &cond);
1963 if (res) {
1964 /* Impart failed. Signal any other waiting impart threads */
1967 }
1968
1969 ast_cond_destroy(&cond.cond);
1970 ast_mutex_destroy(&cond.lock);
1971
1972 return res;
1973}
ast_cond_t cond
Definition: app_sla.c:336
void bridge_channel_impart_signal(struct ast_channel *chan)
Definition: bridge.c:1651
static int bridge_impart_internal(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags, struct bridge_channel_impart_cond *cond)
Definition: bridge.c:1846
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
@ AST_BRIDGE_AFTER_CB_REASON_IMPART_FAILED
Definition: bridge_after.h:49
#define ast_cond_destroy(cond)
Definition: lock.h:206
#define ast_cond_init(cond, attr)
Definition: lock.h:205
#define ast_mutex_init(pmutex)
Definition: lock.h:190
#define ast_mutex_destroy(a)
Definition: lock.h:192
const ast_string_field uniqueid
Definition: bridge.h:405
Internal bridge impart wait condition and associated conditional.
Definition: bridge.c:1544

References AST_BRIDGE_AFTER_CB_REASON_IMPART_FAILED, ast_bridge_discard_after_callback(), ast_channel_name(), ast_cond_destroy, ast_cond_init, ast_mutex_destroy, ast_mutex_init, bridge_channel_impart_signal(), bridge_impart_internal(), cond, NULL, SCOPE_TRACE, and ast_bridge::uniqueid.

Referenced by add_to_dial_bridge(), ast_bridge_add_channel(), ast_bridge_call_with_flags(), AST_TEST_DEFINE(), ast_unreal_channel_push_to_bridge(), attended_transfer_bridge(), blind_transfer_bridge(), conf_announce_channel_push(), conf_start_record(), control_swap_channel_in_bridge(), feature_attended_transfer(), local_call(), parking_blind_transfer_park(), recalling_exit(), refer_incoming_invite_request(), and retransfer_enter().

◆ ast_bridge_is_video_src()

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 3960 of file bridge.c.

3961{
3962 int res = 0;
3963
3964 ast_bridge_lock(bridge);
3965 switch (bridge->softmix.video_mode.mode) {
3967 break;
3970 res = 1;
3971 }
3972 break;
3975 res = 1;
3976 } else if (bridge->softmix.video_mode.mode_data.talker_src_data.chan_old_vsrc == chan) {
3977 res = 2;
3978 }
3980 break;
3981 }
3982 ast_bridge_unlock(bridge);
3983 return res;
3984}
struct ast_bridge_video_mode video_mode
Definition: bridge.h:283
struct ast_bridge_video_single_src_data single_src_data
Definition: bridge.h:167
struct ast_bridge_video_talker_src_data talker_src_data
Definition: bridge.h:168
union ast_bridge_video_mode::@191 mode_data
enum ast_bridge_video_mode_type mode
Definition: bridge.h:164
struct ast_channel * chan_vsrc
Definition: bridge.h:120
struct ast_channel * chan_old_vsrc
Definition: bridge.h:131
struct ast_channel * chan_vsrc
Definition: bridge.h:127
struct ast_bridge_softmix softmix
Definition: bridge.h:371

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_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_mode::single_src_data, ast_bridge::softmix, ast_bridge_video_mode::talker_src_data, and ast_bridge_softmix::video_mode.

Referenced by handle_video_on_exit(), handle_video_on_join(), softmix_bridge_write_video(), and softmix_pass_video_top_priority().

◆ ast_bridge_join()

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:

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)
Definition: bridge.c:1690

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 1690 of file bridge.c.

1696{
1697 struct ast_bridge_channel *bridge_channel;
1698 int res = 0;
1699 SCOPE_TRACE(1, "%s Bridge: %s\n", ast_channel_name(chan), bridge->uniqueid);
1700
1701 bridge_channel = bridge_channel_internal_alloc(bridge);
1702 if (flags & AST_BRIDGE_JOIN_PASS_REFERENCE) {
1703 ao2_ref(bridge, -1);
1704 }
1705 if (!bridge_channel) {
1706 ao2_t_cleanup(swap, "Error exit: bridge_channel alloc failed");
1707 res = -1;
1708 goto join_exit;
1709 }
1710/* 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. */
1712 if (!features) {
1713 ao2_ref(bridge_channel, -1);
1714 ao2_t_cleanup(swap, "Error exit: features is NULL");
1715 res = -1;
1716 goto join_exit;
1717 }
1718 if (tech_args) {
1719 bridge_channel->tech_args = *tech_args;
1720 }
1721
1724 res = -1;
1725 } else {
1727 }
1729 bridge_channel->thread = pthread_self();
1730 bridge_channel->chan = chan;
1731 bridge_channel->swap = swap;
1732 bridge_channel->features = features;
1733 bridge_channel->inhibit_colp = !!(flags & AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP);
1734
1735 /* allow subclass to peek at upcoming push operation */
1736 if (bridge->v_table->push_peek && !res) {
1737 struct ast_bridge_channel *bcswap = NULL;
1738
1740 if (bridge_channel->swap) {
1741 bcswap = bridge_find_channel(bridge, bridge_channel->swap);
1742 }
1743 res = bridge->v_table->push_peek(bridge, bridge_channel, bcswap);
1745 }
1746
1747 if (!res) {
1748 res = bridge_channel_internal_join(bridge_channel);
1749 }
1750
1751 /* Cleanup all the data in the bridge channel after it leaves the bridge. */
1755 /* Due to a race condition, we lock the bridge channel here for ast_bridge_channel_get_chan */
1756 ao2_lock(bridge_channel);
1757 bridge_channel->chan = NULL;
1758 ao2_unlock(bridge_channel);
1759 /* If bridge_channel->swap is not NULL then the join failed. */
1760 ao2_t_cleanup(bridge_channel->swap, "Bridge complete: join failed");
1761 bridge_channel->swap = NULL;
1762 bridge_channel->features = NULL;
1763
1764 ao2_ref(bridge_channel, -1);
1765
1766join_exit:
1771 /* Claim the after bridge goto is an async goto destination. */
1775 }
1776 return res;
1777}
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1935
struct ast_bridge_channel * bridge_find_channel(struct ast_bridge *bridge, struct ast_channel *chan)
Definition: bridge.c:1498
int ast_bridge_setup_after_goto(struct ast_channel *chan)
Setup any after bridge goto location to begin execution.
Definition: bridge_after.c:435
void ast_bridge_run_after_callback(struct ast_channel *chan)
Run any after bridge callback.
Definition: bridge_after.c:212
struct ast_bridge_channel * bridge_channel_internal_alloc(struct ast_bridge *bridge)
int bridge_channel_internal_join(struct ast_bridge_channel *bridge_channel)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
@ AST_FLAG_ZOMBIE
Definition: channel.h:1007
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2487
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
@ AST_SOFTHANGUP_ASYNCGOTO
Definition: channel.h:1146
struct ast_channel * swap
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_bridge_features * features
unsigned int inhibit_colp
struct ast_bridge_tech_optimizations tech_args
ast_bridge_push_channel_fn push_peek
Definition: bridge.h:277
const struct ast_bridge_methods * v_table
Definition: bridge.h:355
#define ast_test_flag(p, flag)
Definition: utils.h:63

References ao2_lock, ao2_ref, ao2_t_cleanup, ao2_unlock, ast_assert, 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_channel_flags(), ast_channel_internal_bridge_channel_set(), ast_channel_lock, ast_channel_name(), ast_channel_softhangup_internal_flag(), ast_channel_unlock, AST_FLAG_ZOMBIE, AST_SOFTHANGUP_ASYNCGOTO, ast_softhangup_nolock(), ast_test_flag, ast_bridge_channel::bridge, bridge_channel_impart_signal(), bridge_channel_internal_alloc(), bridge_channel_internal_join(), bridge_find_channel(), ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_channel::inhibit_colp, NULL, ast_bridge_methods::push_peek, SCOPE_TRACE, 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(), agent_run(), ast_bridge_call_with_flags(), bridge_exec(), bridgeadd_exec(), bridgewait_exec(), confbridge_exec(), park_and_announce_app_exec(), park_app_exec(), and parked_call_app_exec().

◆ ast_bridge_kick()

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:

ast_bridge_kick(bridge, chan);
int ast_bridge_kick(struct ast_bridge *bridge, struct ast_channel *chan)
Kick a channel from a bridge.
Definition: bridge.c:2048

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 2048 of file bridge.c.

2049{
2050 struct ast_bridge_channel *bridge_channel;
2051 int res;
2052
2054
2055 /* Try to find the channel that we want to kick. */
2056 if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
2058 return -1;
2059 }
2060
2061 res = ast_bridge_channel_queue_callback(bridge_channel, 0, kick_it, NULL, 0);
2062
2064
2065 return res;
2066}
static void kick_it(struct ast_bridge_channel *bridge_channel, const void *payload, size_t payload_size)
Definition: bridge.c:2043
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.

References ast_bridge_channel_queue_callback(), ast_bridge_lock, ast_bridge_unlock, ast_bridge_channel::bridge, bridge_find_channel(), ast_bridge_channel::chan, kick_it(), and NULL.

Referenced by handle_bridge_kick_channel(), and manager_bridge_kick().

◆ ast_bridge_merge()

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:

ast_bridge_merge(dst_bridge, src_bridge, 0, NULL, 0);
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.
Definition: bridge.c:2369

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

Definition at line 2369 of file bridge.c.

2370{
2371 int res;
2372
2373 /* Sanity check. */
2374 ast_assert(dst_bridge && src_bridge);
2375
2376 ast_bridge_lock_both(dst_bridge, src_bridge);
2377 res = bridge_merge_locked(dst_bridge, src_bridge, merge_best_direction, kick_me, num_kick);
2378 ast_bridge_unlock(src_bridge);
2379 ast_bridge_unlock(dst_bridge);
2380 return res;
2381}
static int bridge_merge_locked(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, int merge_best_direction, struct ast_channel **kick_me, unsigned int num_kick)
Definition: bridge.c:2285
#define ast_bridge_lock_both(bridge1, bridge2)
Lock two bridges.
Definition: bridge.h:492

References ast_assert, ast_bridge_lock_both, ast_bridge_unlock, and bridge_merge_locked().

◆ ast_bridge_merge_inhibit()

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 3069 of file bridge.c.

3070{
3071 ast_bridge_lock(bridge);
3073 ast_bridge_unlock(bridge);
3074}
void bridge_merge_inhibit_nolock(struct ast_bridge *bridge, int request)
Definition: bridge.c:3060
static int request(void *obj)
Definition: chan_pjsip.c:2605

References ast_bridge_lock, ast_bridge_unlock, bridge_merge_inhibit_nolock(), and request().

Referenced by attended_transfer_properties_shutdown(), consulting_exit(), and feature_attended_transfer().

◆ ast_bridge_move()

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 2529 of file bridge.c.

2530{
2531 int res;
2532
2533 ast_bridge_lock_both(dst_bridge, src_bridge);
2534 res = bridge_move_locked(dst_bridge, src_bridge, chan, swap, attempt_recovery);
2535 ast_bridge_unlock(src_bridge);
2536 ast_bridge_unlock(dst_bridge);
2537 return res;
2538}
static int bridge_move_locked(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_channel *chan, struct ast_channel *swap, int attempt_recovery)
Definition: bridge.c:2468

References ast_bridge_lock_both, ast_bridge_unlock, bridge_move_locked(), ast_bridge_channel::chan, and ast_bridge_channel::swap.

Referenced by agent_connect_caller(), parked_call_app_exec(), and parking_park_bridge_channel().

◆ ast_bridge_notify_masquerade()

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 1511 of file bridge.c.

1512{
1513 struct ast_bridge_channel *bridge_channel;
1514 struct ast_bridge *bridge;
1515
1516 /* Safely get the bridge_channel pointer for the chan. */
1517 ast_channel_lock(chan);
1518 bridge_channel = ast_channel_get_bridge_channel(chan);
1519 ast_channel_unlock(chan);
1520 if (!bridge_channel) {
1521 /* Not in a bridge */
1522 return;
1523 }
1524
1525 ast_bridge_channel_lock_bridge(bridge_channel);
1526 bridge = bridge_channel->bridge;
1527 if (bridge_channel == bridge_find_channel(bridge, chan)) {
1528/*
1529 * XXX ASTERISK-22366 this needs more work. The channels need
1530 * to be made compatible again if the formats change. The
1531 * bridge_channel thread needs to monitor for this case.
1532 */
1533 /* The channel we want to notify is still in a bridge. */
1534 bridge->v_table->notify_masquerade(bridge, bridge_channel);
1535 bridge_reconfigured(bridge, 1);
1536 }
1537 ast_bridge_unlock(bridge);
1538 ao2_ref(bridge_channel, -1);
1539}
void bridge_reconfigured(struct ast_bridge *bridge, unsigned int colp_update)
Definition: bridge.c:1472
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
Lock the bridge associated with the bridge channel.
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:10608
ast_bridge_notify_masquerade_fn notify_masquerade
Definition: bridge.h:273

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

Referenced by channel_do_masquerade().

◆ ast_bridge_number_video_src()

int ast_bridge_number_video_src ( struct ast_bridge bridge)

◆ ast_bridge_peer()

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 4144 of file bridge.c.

4145{
4146 struct ast_channel *peer;
4147
4149 peer = ast_bridge_peer_nolock(bridge, chan);
4151
4152 return peer;
4153}
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:4116
Main Channel structure associated with a channel.
struct ast_bridge * bridge

References ast_bridge_lock, ast_bridge_peer_nolock(), ast_bridge_unlock, and ast_channel::bridge.

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

◆ ast_bridge_peer_nolock()

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 4116 of file bridge.c.

4117{
4118 struct ast_channel *peer = NULL;
4119 struct ast_bridge_channel *iter;
4120
4121 /* Asking for the peer channel only makes sense on a two-party bridge. */
4122 if (bridge->num_channels == 2
4125 int in_bridge = 0;
4126
4128 if (iter->chan != chan) {
4129 peer = iter->chan;
4130 } else {
4131 in_bridge = 1;
4132 }
4133 }
4134 if (in_bridge && peer) {
4135 ast_channel_ref(peer);
4136 } else {
4137 peer = NULL;
4138 }
4139 }
4140
4141 return peer;
4142}
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2995
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct ast_bridge_channel::@193 entry
unsigned int in_bridge
struct ast_bridge_channels_list channels
Definition: bridge.h:367
unsigned int num_channels
Definition: bridge.h:377
struct ast_bridge_technology * technology
Definition: bridge.h:359

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

Referenced by ast_bridge_peer(), ast_refer_notify_transfer_request(), and feature_automixmonitor().

◆ ast_bridge_peers()

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 4105 of file bridge.c.

4106{
4107 struct ao2_container *channels;
4108
4109 ast_bridge_lock(bridge);
4111 ast_bridge_unlock(bridge);
4112
4113 return channels;
4114}
struct ao2_container * ast_bridge_peers_nolock(struct ast_bridge *bridge)
Get a container of all channels in the bridge.
Definition: bridge.c:4087
static struct channel_usage channels
Generic container type.

References ast_bridge_lock, ast_bridge_peers_nolock(), ast_bridge_unlock, and channels.

◆ ast_bridge_peers_nolock()

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 4087 of file bridge.c.

4088{
4089 struct ao2_container *channels;
4090 struct ast_bridge_channel *iter;
4091
4094 if (!channels) {
4095 return NULL;
4096 }
4097
4099 ao2_link(channels, iter->chan);
4100 }
4101
4102 return channels;
4103}
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
#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
static int channel_hash(const void *obj, int flags)
Definition: bridge.c:4042
static int channel_cmp(void *obj, void *arg, int flags)
Definition: bridge.c:4065

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_hash, ao2_link, AST_LIST_TRAVERSE, ast_bridge_channel::bridge, ast_bridge_channel::chan, channel_cmp(), channel_hash(), channels, ast_bridge::channels, ast_bridge_channel::entry, and NULL.

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

◆ ast_bridge_queue_action()

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 314 of file bridge.c.

315{
316 struct ast_frame *dup;
317
318 dup = ast_frdup(action);
319 if (!dup) {
320 return -1;
321 }
322 bridge_queue_action_nodup(bridge, dup);
323 return 0;
324}
static void bridge_queue_action_nodup(struct ast_bridge *bridge, struct ast_frame *action)
Definition: bridge.c:303
#define ast_frdup(fr)
Copies a frame.
Data structure associated with a single frame of data.

References ast_frdup, and bridge_queue_action_nodup().

Referenced by bridge_dissolve().

◆ ast_bridge_queue_everyone_else()

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 1093 of file bridge_channel.c.

1094{
1095 struct ast_bridge_channel *cur;
1096 int not_written = -1;
1097
1098 if (frame->frametype == AST_FRAME_NULL) {
1099 /* "Accept" the frame and discard it. */
1100 return 0;
1101 }
1102
1104 if (cur == bridge_channel) {
1105 continue;
1106 }
1107 if (!ast_bridge_channel_queue_frame(cur, frame)) {
1108 not_written = 0;
1109 }
1110 }
1111 return not_written;
1112}
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
Write a frame to the specified bridge_channel.
@ AST_FRAME_NULL
enum ast_frame_type frametype

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

Referenced by ari_bridges_play_new(), bridge_hold(), bridge_ringing(), bridge_unhold(), holding_bridge_write(), native_bridge_write(), native_rtp_bridge_write(), simple_bridge_write(), softmix_bridge_write(), softmix_bridge_write_control(), softmix_bridge_write_text(), and softmix_bridge_write_video().

◆ ast_bridge_remove()

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:

ast_bridge_remove(bridge, chan);
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
Remove a channel from a bridge.
Definition: bridge.c:2020

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 2020 of file bridge.c.

2021{
2022 struct ast_bridge_channel *bridge_channel;
2023
2024 ast_debug(1, "Removing channel %s from bridge %s\n",
2026
2028
2029 /* Try to find the channel that we want to remove */
2030 if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
2032 return -1;
2033 }
2034
2035 ast_bridge_channel_leave_bridge(bridge_channel,
2037
2039
2040 return 0;
2041}

References ast_bridge_channel_leave_bridge(), ast_bridge_lock, ast_bridge_unlock, AST_CAUSE_NORMAL_CLEARING, ast_channel_name(), ast_debug, ast_bridge_channel::bridge, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, bridge_find_channel(), ast_bridge_channel::chan, and ast_bridge::uniqueid.

Referenced by action_kick_last(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), execute_menu_entry(), kick_conference_participant(), and leave_marked().

◆ ast_bridge_remove_video_src()

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.

Definition at line 3986 of file bridge.c.

3987{
3988 ast_bridge_lock(bridge);
3989 switch (bridge->softmix.video_mode.mode) {
3991 break;
3996 }
3998 }
3999 break;
4004 }
4007 }
4011 }
4013 }
4015 break;
4016 }
4017 ast_bridge_unlock(bridge);
4018}
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:3006

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_channel_unref, ast_bridge_video_talker_src_data::average_talking_energy, 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_video_mode::mode, ast_bridge_video_mode::mode_data, NULL, ast_bridge_video_mode::single_src_data, ast_bridge::softmix, ast_bridge_video_mode::talker_src_data, and ast_bridge_softmix::video_mode.

Referenced by bridge_channel_internal_join(), and handle_video_on_exit().

◆ ast_bridge_set_binaural_active()

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 3774 of file bridge.c.

3775{
3776 ast_bridge_lock(bridge);
3777 bridge->softmix.binaural_active = binaural_active;
3778 ast_bridge_unlock(bridge);
3779}
unsigned int binaural_active
Definition: bridge.h:299

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

Referenced by join_conference_bridge().

◆ ast_bridge_set_internal_sample_rate()

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 3781 of file bridge.c.

3782{
3783 ast_bridge_lock(bridge);
3784 bridge->softmix.internal_sample_rate = sample_rate;
3785 ast_bridge_unlock(bridge);
3786}
unsigned int internal_sample_rate
The internal sample rate softmix uses to mix channels.
Definition: bridge.h:289

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

Referenced by join_conference_bridge().

◆ ast_bridge_set_maximum_sample_rate()

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 3788 of file bridge.c.

3789{
3790 ast_bridge_lock(bridge);
3791 bridge->softmix.maximum_sample_rate = sample_rate;
3792 ast_bridge_unlock(bridge);
3793}
unsigned int maximum_sample_rate
The maximum sample rate softmix uses to mix channels.
Definition: bridge.h:310

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

Referenced by join_conference_bridge().

◆ ast_bridge_set_mixing_interval()

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 3767 of file bridge.c.

3768{
3769 ast_bridge_lock(bridge);
3770 bridge->softmix.internal_mixing_interval = mixing_interval;
3771 ast_bridge_unlock(bridge);
3772}
unsigned int internal_mixing_interval
The mixing interval indicates how quickly softmix mixing should occur to mix audio.
Definition: bridge.h:297

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

Referenced by join_conference_bridge().

◆ ast_bridge_set_remb_estimated_bitrate()

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 3876 of file bridge.c.

3877{
3879
3880 ast_bridge_lock(bridge);
3881 bridge->softmix.video_mode.mode_data.sfu_data.estimated_bitrate = estimated_bitrate;
3882 ast_bridge_unlock(bridge);
3883}
struct ast_bridge_video_sfu_data sfu_data
Definition: bridge.h:169

References ast_assert, ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, ast_bridge_video_sfu_data::estimated_bitrate, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_mode::sfu_data, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by join_conference_bridge().

◆ ast_bridge_set_remb_send_interval()

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 3858 of file bridge.c.

3859{
3861
3862 ast_bridge_lock(bridge);
3863 bridge->softmix.video_mode.mode_data.sfu_data.remb_send_interval = remb_send_interval;
3864 ast_bridge_unlock(bridge);
3865}
unsigned int remb_send_interval
Definition: bridge.h:155

References ast_assert, ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_sfu_data::remb_send_interval, ast_bridge_video_mode::sfu_data, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by join_conference_bridge().

◆ ast_bridge_set_send_sdp_label()

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 4035 of file bridge.c.

4036{
4037 ast_bridge_lock(bridge);
4038 bridge->softmix.send_sdp_label = send_sdp_label;
4039 ast_bridge_unlock(bridge);
4040}
unsigned int send_sdp_label
Definition: bridge.h:304

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

Referenced by bridge_stasis_new(), and join_conference_bridge().

◆ ast_bridge_set_sfu_video_mode()

void ast_bridge_set_sfu_video_mode ( struct ast_bridge bridge)

Set the bridge to be a selective forwarding unit.

Definition at line 3843 of file bridge.c.

3844{
3845 ast_bridge_lock(bridge);
3846 cleanup_video_mode(bridge);
3848 ast_bridge_unlock(bridge);
3849}
static void cleanup_video_mode(struct ast_bridge *bridge)
Definition: bridge.c:3795

References ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, cleanup_video_mode(), ast_bridge_video_mode::mode, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by bridge_stasis_new(), and join_conference_bridge().

◆ ast_bridge_set_single_src_video_mode()

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.

Definition at line 3818 of file bridge.c.

3819{
3820 ast_bridge_lock(bridge);
3821 cleanup_video_mode(bridge);
3823 if (video_src_chan) {
3825 ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
3826 bridge->name, bridge->uniqueid,
3827 ast_channel_name(video_src_chan),
3828 ast_channel_uniqueid(video_src_chan));
3829 ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE);
3830 }
3832 ast_bridge_unlock(bridge);
3833}
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4294
@ AST_CONTROL_VIDUPDATE
#define ast_verb(level,...)
void ast_bridge_publish_state(struct ast_bridge *bridge)
Publish the state of a bridge.
const ast_string_field name
Definition: bridge.h:405

References ast_bridge_lock, ast_bridge_publish_state(), ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, ast_channel_name(), ast_channel_ref, ast_channel_uniqueid(), AST_CONTROL_VIDUPDATE, ast_indicate(), ast_verb, ast_bridge_video_single_src_data::chan_vsrc, cleanup_video_mode(), ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge::name, ast_bridge_video_mode::single_src_data, ast_bridge::softmix, ast_bridge::uniqueid, and ast_bridge_softmix::video_mode.

Referenced by action_confbridgesetsinglevideosrc(), bridge_set_video_source_cb(), bridge_stasis_new(), execute_menu_entry(), handle_video_on_exit(), and handle_video_on_join().

◆ ast_bridge_set_talker_src_video_mode()

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.

Definition at line 3835 of file bridge.c.

3836{
3837 ast_bridge_lock(bridge);
3838 cleanup_video_mode(bridge);
3840 ast_bridge_unlock(bridge);
3841}

References ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, cleanup_video_mode(), ast_bridge_video_mode::mode, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by ast_ari_bridges_clear_video_source(), bridge_stasis_new(), handle_video_on_exit(), and join_conference_bridge().

◆ ast_bridge_set_transfer_variables()

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 4421 of file bridge.c.

4422{
4423 char *writevar;
4424 char *erasevar;
4425
4426 if (attended) {
4427 writevar = ATTENDEDTRANSFER;
4428 erasevar = BLINDTRANSFER;
4429 } else {
4430 writevar = BLINDTRANSFER;
4431 erasevar = ATTENDEDTRANSFER;
4432 }
4433
4434 pbx_builtin_setvar_helper(chan, writevar, value);
4435 pbx_builtin_setvar_helper(chan, erasevar, NULL);
4436}
#define BLINDTRANSFER
Definition: bridge.c:147
#define ATTENDEDTRANSFER
Definition: bridge.c:150
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.
int value
Definition: syslog.c:37

References ATTENDEDTRANSFER, BLINDTRANSFER, NULL, pbx_builtin_setvar_helper(), and value.

Referenced by dial_transfer(), manager_park(), park_local_transfer(), parking_park_bridge_channel(), and set_transfer_variables_all().

◆ ast_bridge_set_video_update_discard()

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 3851 of file bridge.c.

3852{
3853 ast_bridge_lock(bridge);
3854 bridge->softmix.video_mode.video_update_discard = video_update_discard;
3855 ast_bridge_unlock(bridge);
3856}
unsigned int video_update_discard
Definition: bridge.h:172

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 bridge_stasis_new(), and join_conference_bridge().

◆ ast_bridge_suspend()

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:

ast_bridge_suspend(bridge, chan);
int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan)
Suspend a channel temporarily from a bridge.
Definition: bridge.c:3076

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 3076 of file bridge.c.

3077{
3078 struct ast_bridge_channel *bridge_channel;
3079/* XXX ASTERISK-21271 the case of a dissolved bridge while channel is suspended is not handled. */
3080/* XXX ASTERISK-21271 suspend/unsuspend needs to be rethought. The caller must block until it has successfully suspended the channel for temporary control. */
3081/* 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. */
3082
3084
3085 if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
3087 return -1;
3088 }
3089
3091
3093
3094 return 0;
3095}
void bridge_channel_internal_suspend_nolock(struct ast_bridge_channel *bridge_channel)

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_channel::bridge, bridge_channel_internal_suspend_nolock(), bridge_find_channel(), and ast_bridge_channel::chan.

Referenced by conf_moh_start(), and conf_moh_stop().

◆ ast_bridge_transfer_acquire_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 4477 of file bridge.c.

4478{
4479 struct ast_bridge *bridge;
4480
4481 ast_channel_lock(chan);
4482 bridge = ast_channel_get_bridge(chan);
4483 ast_channel_unlock(chan);
4484
4485 if (bridge && ast_test_flag(&bridge->feature_flags,
4487 ao2_ref(bridge, -1);
4488 bridge = NULL;
4489 }
4490
4491 return bridge;
4492}
@ AST_BRIDGE_FLAG_MASQUERADE_ONLY
@ AST_BRIDGE_FLAG_INVISIBLE
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10560
struct ast_flags feature_flags
Definition: bridge.h:373

References ao2_ref, AST_BRIDGE_FLAG_INVISIBLE, AST_BRIDGE_FLAG_MASQUERADE_ONLY, ast_channel_get_bridge(), ast_channel_lock, ast_channel_unlock, ast_test_flag, ast_bridge::feature_flags, and NULL.

Referenced by ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), ast_refer_notify_transfer_request(), and invite_replaces().

◆ ast_bridge_transfer_attended()

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 4746 of file bridge.c.

4748{
4749 RAII_VAR(struct ast_bridge *, to_transferee_bridge, NULL, ao2_cleanup);
4750 RAII_VAR(struct ast_bridge *, to_target_bridge, NULL, ao2_cleanup);
4751 RAII_VAR(struct ast_bridge_channel *, to_transferee_bridge_channel, NULL, ao2_cleanup);
4752 RAII_VAR(struct ast_bridge_channel *, to_target_bridge_channel, NULL, ao2_cleanup);
4754 RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
4755 RAII_VAR(struct ast_attended_transfer_message *, transfer_msg, NULL, ao2_cleanup);
4756 struct ast_bridge *the_bridge = NULL;
4757 struct ast_channel *chan_bridged;
4758 struct ast_channel *chan_unbridged;
4759 int transfer_prohibited;
4760 int do_bridge_transfer;
4761 enum ast_transfer_result res;
4762 const char *app = NULL;
4763 int hangup_target = 0;
4764
4765 to_transferee_bridge = ast_bridge_transfer_acquire_bridge(to_transferee);
4766 to_target_bridge = ast_bridge_transfer_acquire_bridge(to_transfer_target);
4767
4768 transfer_msg = ast_attended_transfer_message_create(1, to_transferee, to_transferee_bridge,
4769 to_transfer_target, to_target_bridge, NULL, NULL);
4770 if (!transfer_msg) {
4771 ast_log(LOG_ERROR, "Unable to create Stasis publication for attended transfer from %s\n",
4772 ast_channel_name(to_transferee));
4774 }
4775
4776 /* They can't both be unbridged, you silly goose! */
4777 if (!to_transferee_bridge && !to_target_bridge) {
4779 goto end;
4780 }
4781
4782 ast_channel_lock(to_transferee);
4783 to_transferee_bridge_channel = ast_channel_get_bridge_channel(to_transferee);
4784 ast_channel_unlock(to_transferee);
4785
4786 ast_channel_lock(to_transfer_target);
4787 to_target_bridge_channel = ast_channel_get_bridge_channel(to_transfer_target);
4788 ast_channel_unlock(to_transfer_target);
4789
4790 if (to_transferee_bridge_channel) {
4791 /* Take off hold if they are on hold. */
4792 if (ast_bridge_channel_write_unhold(to_transferee_bridge_channel)) {
4793 ast_log(LOG_ERROR, "Transferee channel disappeared during transfer!\n");
4795 goto end;
4796 }
4797 }
4798
4799 if (to_target_bridge_channel) {
4800 const char *target_complete_sound;
4801
4802 /* Take off hold if they are on hold. */
4803 if (ast_bridge_channel_write_unhold(to_target_bridge_channel)) {
4804 ast_log(LOG_ERROR, "Target channel disappeared during transfer!\n");
4806 goto end;
4807 }
4808
4809 /* Is there a courtesy sound to play to the target? */
4810 ast_channel_lock(to_transfer_target);
4811 target_complete_sound = pbx_builtin_getvar_helper(to_transfer_target,
4812 "ATTENDED_TRANSFER_COMPLETE_SOUND");
4813 if (!ast_strlen_zero(target_complete_sound)) {
4814 target_complete_sound = ast_strdupa(target_complete_sound);
4815 } else {
4816 target_complete_sound = NULL;
4817 }
4818 ast_channel_unlock(to_transfer_target);
4819 if (!target_complete_sound) {
4820 ast_channel_lock(to_transferee);
4821 target_complete_sound = pbx_builtin_getvar_helper(to_transferee,
4822 "ATTENDED_TRANSFER_COMPLETE_SOUND");
4823 if (!ast_strlen_zero(target_complete_sound)) {
4824 target_complete_sound = ast_strdupa(target_complete_sound);
4825 } else {
4826 target_complete_sound = NULL;
4827 }
4828 ast_channel_unlock(to_transferee);
4829 }
4830 if (target_complete_sound) {
4831 ast_bridge_channel_write_playfile(to_target_bridge_channel, NULL,
4832 target_complete_sound, NULL);
4833 }
4834 }
4835
4836 /* Let's get the easy one out of the way first */
4837 if (to_transferee_bridge && to_target_bridge) {
4838
4839 if (!to_transferee_bridge_channel || !to_target_bridge_channel) {
4841 goto end;
4842 }
4843
4844 ast_bridge_lock_both(to_transferee_bridge, to_target_bridge);
4845 res = two_bridge_attended_transfer(to_transferee, to_transferee_bridge_channel,
4846 to_transfer_target, to_target_bridge_channel,
4847 to_transferee_bridge, to_target_bridge, transfer_msg);
4848 ast_bridge_unlock(to_transferee_bridge);
4849 ast_bridge_unlock(to_target_bridge);
4850
4851 hangup_target = 1;
4852 goto end;
4853 }
4854
4855 the_bridge = to_transferee_bridge ?: to_target_bridge;
4856 chan_bridged = to_transferee_bridge ? to_transferee : to_transfer_target;
4857 chan_unbridged = to_transferee_bridge ? to_transfer_target : to_transferee;
4858
4859 /*
4860 * Race condition makes it possible for app to be NULL, so get the app prior to
4861 * transferring with a fallback of "unknown".
4862 */
4863 app = ast_strdupa(ast_channel_appl(chan_unbridged) ?: "unknown");
4864
4865 {
4866 int chan_count;
4868
4869 channels = ast_bridge_peers_nolock(the_bridge);
4870 if (!channels) {
4872 goto end;
4873 }
4874 chan_count = ao2_container_count(channels);
4875 if (chan_count <= 1) {
4877 goto end;
4878 }
4879 transfer_prohibited = ast_test_flag(&the_bridge->feature_flags,
4881 do_bridge_transfer = ast_test_flag(&the_bridge->feature_flags,
4883 chan_count > 2;
4884 }
4885
4886 if (transfer_prohibited) {
4888 goto end;
4889 }
4890
4891 set_transfer_variables_all(to_transferee, channels, 1);
4892
4893 if (do_bridge_transfer) {
4894 /*
4895 * Hang up the target if it was bridged. Note, if it is not bridged
4896 * it is hung up during the masquerade.
4897 */
4898 hangup_target = chan_bridged == to_transfer_target;
4899 ast_bridge_lock(the_bridge);
4900 res = attended_transfer_bridge(chan_bridged, chan_unbridged, the_bridge, NULL, transfer_msg);
4901 ast_bridge_unlock(the_bridge);
4902 goto end;
4903 }
4904
4905 transferee = get_transferee(channels, chan_bridged);
4906 if (!transferee) {
4908 goto end;
4909 }
4910
4911 if (bridge_channel_internal_queue_attended_transfer(transferee, chan_unbridged)) {
4913 goto end;
4914 }
4915
4916 ast_bridge_remove(the_bridge, chan_bridged);
4917
4920
4921end:
4922 if ((res == AST_BRIDGE_TRANSFER_SUCCESS && hangup_target) || res == AST_BRIDGE_TRANSFER_FAIL) {
4923 ast_softhangup(to_transfer_target, AST_SOFTHANGUP_DEV);
4924 }
4925
4926 transfer_msg->result = res;
4928 return res;
4929}
static const char app[]
Definition: app_adsiprog.c:56
ast_mutex_t lock
Definition: app_sla.c:337
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
static struct ast_channel * get_transferee(struct ao2_container *channels, struct ast_channel *transferer)
Definition: bridge.c:4251
static enum ast_transfer_result two_bridge_attended_transfer(struct ast_channel *to_transferee, struct ast_bridge_channel *to_transferee_bridge_channel, struct ast_channel *to_transfer_target, struct ast_bridge_channel *to_target_bridge_channel, struct ast_bridge *to_transferee_bridge, struct ast_bridge *to_target_bridge, struct ast_attended_transfer_message *transfer_msg)
Definition: bridge.c:4680
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:4290
struct ast_bridge * ast_bridge_transfer_acquire_bridge(struct ast_channel *chan)
Acquire the channel's bridge for transfer purposes.
Definition: bridge.c:4477
int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan)
Remove a channel from a bridge.
Definition: bridge.c:2020
static void set_transfer_variables_all(struct ast_channel *transferer, struct ao2_container *channels, int is_attended)
Definition: bridge.c:4452
ast_transfer_result
Definition: bridge.h:1102
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
Write an unhold frame into the bridge.
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.
int bridge_channel_internal_queue_attended_transfer(struct ast_channel *transferee, struct ast_channel *unbridged_chan)
@ AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY
@ AST_BRIDGE_FLAG_TRANSFER_PROHIBITED
const char * ast_channel_appl(const struct ast_channel *chan)
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2500
@ AST_SOFTHANGUP_DEV
Definition: channel.h:1141
char * end
Definition: eagi_proxy.c:73
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:587
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
void ast_bridge_publish_attended_transfer(struct ast_attended_transfer_message *transfer_msg)
Publish an attended transfer.
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.
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.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Message representing attended transfer.
#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

References ao2_cleanup, ao2_container_count(), app, 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_appl(), ast_channel_get_bridge_channel(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_log, ast_softhangup(), AST_SOFTHANGUP_DEV, ast_strdupa, ast_strlen_zero(), ast_test_flag, attended_transfer_bridge(), bridge_channel_internal_queue_attended_transfer(), channels, end, ast_bridge::feature_flags, get_transferee(), lock, LOG_ERROR, NULL, pbx_builtin_getvar_helper(), RAII_VAR, SCOPED_LOCK, set_transfer_variables_all(), and two_bridge_attended_transfer().

Referenced by analog_attempt_transfer(), AST_TEST_DEFINE(), attempt_transfer(), and refer_attended_task().

◆ ast_bridge_transfer_blind()

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 4494 of file bridge.c.

4497{
4498 RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
4499 RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
4501 RAII_VAR(struct ast_channel *, transferee, NULL, ast_channel_cleanup);
4502 RAII_VAR(struct transfer_channel_data *, user_data_wrapper, NULL, ao2_cleanup);
4503 RAII_VAR(struct ast_blind_transfer_message *, transfer_message, NULL, ao2_cleanup);
4504 int do_bridge_transfer;
4505 int transfer_prohibited;
4506 enum ast_transfer_result transfer_result;
4507
4508 transfer_message = ast_blind_transfer_message_create(is_external, transferer, exten, context);
4509 if (!transfer_message) {
4510 /* Out of memory. Not even possible to publish a Stasis message about the
4511 * failure
4512 */
4513 ast_log(LOG_ERROR, "Unable to allocate memory for blind transfer publication from %s\n",
4514 ast_channel_name(transferer));
4516 }
4517
4518 bridge = ast_bridge_transfer_acquire_bridge(transferer);
4519 if (!bridge) {
4520 transfer_result = AST_BRIDGE_TRANSFER_INVALID;
4521 goto publish;
4522 }
4523
4524 ast_bridge_lock(bridge);
4525 transfer_message->bridge = ast_bridge_snapshot_create(bridge);
4526 ast_bridge_unlock(bridge);
4527 if (!transfer_message->bridge) {
4528 transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4529 goto publish;
4530 }
4531
4532 transferee = ast_bridge_peer(bridge, transferer);
4533 if (transferee) {
4534 transfer_message->transferee = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transferee));
4535 if (!transfer_message->transferee) {
4536 transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4537 goto publish;
4538 }
4539 }
4540
4541 ast_channel_lock(transferer);
4542 bridge_channel = ast_channel_get_bridge_channel(transferer);
4543 ast_channel_unlock(transferer);
4544 if (!bridge_channel) {
4545 transfer_result = AST_BRIDGE_TRANSFER_INVALID;
4546 goto publish;
4547 }
4548
4549 user_data_wrapper = ao2_alloc(sizeof(*user_data_wrapper), NULL);
4550 if (!user_data_wrapper) {
4551 transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4552 goto publish;
4553 }
4554
4555 user_data_wrapper->data = user_data;
4556
4557 /* Take off hold if they are on hold. */
4558 ast_bridge_channel_write_unhold(bridge_channel);
4559
4560 transfer_result = try_parking(transferer, context, exten, new_channel_cb, user_data_wrapper);
4561 if (transfer_result == AST_BRIDGE_TRANSFER_SUCCESS) {
4562 goto publish;
4563 }
4564
4565 /* Since parking didn't take control of the user_data_wrapper, we are just going to raise the completed flag now. */
4566 user_data_wrapper->completed = 1;
4567
4568 {
4570
4572 if (!channels) {
4573 transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4574 goto publish;
4575 }
4576 if (ao2_container_count(channels) <= 1) {
4577 transfer_result = AST_BRIDGE_TRANSFER_INVALID;
4578 goto publish;
4579 }
4580 transfer_prohibited = ast_test_flag(&bridge->feature_flags,
4582 do_bridge_transfer = ast_test_flag(&bridge->feature_flags,
4585 }
4586
4587 if (transfer_prohibited) {
4588 transfer_result = AST_BRIDGE_TRANSFER_NOT_PERMITTED;
4589 goto publish;
4590 }
4591
4592 set_transfer_variables_all(transferer, channels, 0);
4593
4594 if (do_bridge_transfer) {
4595 transfer_result = blind_transfer_bridge(is_external, transferer, bridge,
4596 exten, context, transferee, new_channel_cb, user_data_wrapper, transfer_message);
4597 goto publish;
4598 }
4599
4600 /* Reaching this portion means that we're dealing with a two-party bridge */
4601
4602 if (!transferee) {
4603 transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4604 goto publish;
4605 }
4606
4608 new_channel_cb, user_data_wrapper)) {
4609 transfer_result = AST_BRIDGE_TRANSFER_FAIL;
4610 goto publish;
4611 }
4612
4613 ast_bridge_remove(bridge, transferer);
4614 transfer_result = AST_BRIDGE_TRANSFER_SUCCESS;
4615
4616publish:
4617 transfer_message->result = transfer_result;
4618 ast_bridge_publish_blind_transfer(transfer_message);
4619 return transfer_result;
4620}
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
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:4144
static enum ast_transfer_result try_parking(struct ast_channel *transferer, const char *context, const char *exten, transfer_channel_cb new_channel_cb, struct transfer_channel_data *user_data_wrapper)
Definition: bridge.c:4395
static enum ast_transfer_result blind_transfer_bridge(int is_external, struct ast_channel *transferer, struct ast_bridge *bridge, const char *exten, const char *context, struct ast_channel *transferee, transfer_channel_cb new_channel_cb, struct transfer_channel_data *user_data_wrapper, struct ast_blind_transfer_message *transfer_message)
Definition: bridge.c:4180
int bridge_channel_internal_queue_blind_transfer(struct ast_channel *transferee, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:3017
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,...
unsigned char publish
Definition: res_corosync.c:241
void ast_bridge_publish_blind_transfer(struct ast_blind_transfer_message *transfer_message)
Publish a blind transfer event.
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 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.
Message published during a blind transfer.
AO2 object that wraps data for transfer_channel_cb.
Definition: bridge.h:1123

References ao2_alloc, ao2_cleanup, 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_lock, ast_channel_name(), ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_channel_unlock, ast_log, ast_test_flag, blind_transfer_bridge(), bridge_channel_internal_queue_blind_transfer(), channels, voicemailpwcheck::context, lock, LOG_ERROR, NULL, publish, RAII_VAR, SCOPED_LOCK, set_transfer_variables_all(), and try_parking().

Referenced by action_blind_transfer(), blind_transfer_exec(), feature_blind_transfer(), refer_incoming_attended_request(), refer_incoming_blind_request(), and socket_process_helper().

◆ ast_bridge_unreal_optimize_out()

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 2989 of file bridge.c.

2990{
2991 struct ast_bridge *chan_bridge;
2992 struct ast_bridge *peer_bridge;
2993 struct ast_bridge_channel *chan_bridge_channel;
2994 struct ast_bridge_channel *peer_bridge_channel;
2995 int res = 0;
2996
2997 chan_bridge = optimize_lock_chan_stack(chan);
2998 if (!chan_bridge) {
2999 return res;
3000 }
3001 chan_bridge_channel = ast_channel_internal_bridge_channel(chan);
3002
3003 peer_bridge = optimize_lock_peer_stack(peer);
3004 if (peer_bridge) {
3005 peer_bridge_channel = ast_channel_internal_bridge_channel(peer);
3006
3007 res = try_swap_optimize_out(chan_bridge, chan_bridge_channel,
3008 peer_bridge, peer_bridge_channel, pvt);
3009 if (!res) {
3010 res = try_merge_optimize_out(chan_bridge, chan_bridge_channel,
3011 peer_bridge, peer_bridge_channel, pvt);
3012 } else if (0 < res) {
3013 res = 0;
3014 }
3015
3016 /* Release peer locks. */
3017 ast_bridge_unlock(peer_bridge);
3018 ast_bridge_channel_unlock(peer_bridge_channel);
3019 ast_channel_unlock(peer);
3020 }
3021
3022 /* Release chan locks. */
3023 ast_bridge_unlock(chan_bridge);
3024 ast_bridge_channel_unlock(chan_bridge_channel);
3025
3026 return res;
3027}
static int try_merge_optimize_out(struct ast_bridge *chan_bridge, struct ast_bridge_channel *chan_bridge_channel, struct ast_bridge *peer_bridge, struct ast_bridge_channel *peer_bridge_channel, struct ast_unreal_pvt *pvt)
Definition: bridge.c:2938
static struct ast_bridge * optimize_lock_chan_stack(struct ast_channel *chan)
Definition: bridge.c:2648
static struct ast_bridge * optimize_lock_peer_stack(struct ast_channel *peer)
Definition: bridge.c:2693
static int try_swap_optimize_out(struct ast_bridge *chan_bridge, struct ast_bridge_channel *chan_bridge_channel, struct ast_bridge *peer_bridge, struct ast_bridge_channel *peer_bridge_channel, struct ast_unreal_pvt *pvt)
Definition: bridge.c:2814
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.

References ast_bridge_channel_unlock, ast_bridge_unlock, ast_channel_internal_bridge_channel(), ast_channel_unlock, ast_bridge_channel::chan, optimize_lock_chan_stack(), optimize_lock_peer_stack(), try_merge_optimize_out(), and try_swap_optimize_out().

Referenced by got_optimized_out().

◆ ast_bridge_unsuspend()

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:

ast_bridge_unsuspend(bridge, chan);
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan)
Unsuspend a channel from a bridge.
Definition: bridge.c:3097

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 3097 of file bridge.c.

3098{
3099 struct ast_bridge_channel *bridge_channel;
3100/* XXX ASTERISK-21271 the case of a dissolved bridge while channel is suspended is not handled. */
3101
3103
3104 if (!(bridge_channel = bridge_find_channel(bridge, chan))) {
3106 return -1;
3107 }
3108
3110
3112
3113 return 0;
3114}
void bridge_channel_internal_unsuspend_nolock(struct ast_bridge_channel *bridge_channel)

References ast_bridge_lock, ast_bridge_unlock, ast_bridge_channel::bridge, bridge_channel_internal_unsuspend_nolock(), bridge_find_channel(), and ast_bridge_channel::chan.

Referenced by conf_moh_start(), and conf_moh_stop().

◆ ast_bridge_update_talker_src_video_mode()

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.

Definition at line 3885 of file bridge.c.

3886{
3888
3889 /* If the channel doesn't support video, we don't care about it */
3891 return;
3892 }
3893
3894 ast_bridge_lock(bridge);
3896
3897 if (data->chan_vsrc == chan) {
3898 data->average_talking_energy = talker_energy;
3899 } else if ((data->average_talking_energy < talker_energy) && is_keyframe) {
3900 if (data->chan_old_vsrc) {
3902 }
3903 if (data->chan_vsrc) {
3904 data->chan_old_vsrc = data->chan_vsrc;
3906 }
3907 data->chan_vsrc = ast_channel_ref(chan);
3908 data->average_talking_energy = talker_energy;
3909 ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
3910 bridge->name, bridge->uniqueid,
3915 } else if ((data->average_talking_energy < talker_energy) && !is_keyframe) {
3917 } else if (!data->chan_vsrc && is_keyframe) {
3918 data->chan_vsrc = ast_channel_ref(chan);
3919 data->average_talking_energy = talker_energy;
3920 ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
3921 bridge->name, bridge->uniqueid,
3926 } else if (!data->chan_old_vsrc && is_keyframe) {
3927 data->chan_old_vsrc = ast_channel_ref(chan);
3929 }
3930 ast_bridge_unlock(bridge);
3931}
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
@ AST_MEDIA_TYPE_VIDEO
Definition: codec.h:33
int ast_format_cap_has_type(const struct ast_format_cap *cap, enum ast_media_type type)
Find out if the capabilities structure has any formats of a specific type.
Definition: format_cap.c:613
This is used for both SINGLE_SRC_TALKER mode to set what channel should be the current single video f...
Definition: bridge.h:125

References ast_bridge_lock, ast_bridge_publish_state(), ast_bridge_unlock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_ref, ast_channel_uniqueid(), ast_channel_unref, AST_CONTROL_VIDUPDATE, ast_format_cap_has_type(), ast_indicate(), AST_MEDIA_TYPE_VIDEO, ast_verb, ast_bridge_video_talker_src_data::average_talking_energy, ast_bridge_video_talker_src_data::chan_old_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge_video_mode::mode_data, ast_bridge::name, ast_bridge::softmix, ast_bridge_video_mode::talker_src_data, ast_bridge::uniqueid, and ast_bridge_softmix::video_mode.

Referenced by softmix_bridge_write_video().

◆ ast_bridge_vars_set()

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 1281 of file bridge.c.

1282{
1284 pbx_builtin_setvar_helper(chan, "BRIDGEPEER", name);
1285 pbx_builtin_setvar_helper(chan, "BRIDGEPVTCALLID", pvtid);
1287}
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.

References ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_bridge_channel::chan, name, and pbx_builtin_setvar_helper().

Referenced by ast_bridge_channel_leave_bridge_nolock(), set_bridge_peer_vars_2party(), set_bridge_peer_vars_holding(), and set_bridge_peer_vars_multiparty().

◆ ast_bridge_video_mode_to_string()

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 4020 of file bridge.c.

4021{
4022 switch (video_mode) {
4024 return "talker";
4026 return "single";
4028 return "sfu";
4030 default:
4031 return "none";
4032 }
4033}

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(), ast_manager_build_bridge_state_string_prefix(), and handle_bridge_show_specific().

◆ ast_bridges()

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 185 of file bridge.c.

186{
187 return ao2_bump(bridges);
188}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480

References ao2_bump, and bridges.

Referenced by ast_ari_bridges_list(), bridges_scrape_cb(), and manager_bridges_list().

◆ ast_bridges_allow_optimization()

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 3029 of file bridge.c.

3031{
3032 struct merge_direction merge;
3033
3034 if (!bridge_allows_optimization(chan_bridge) || !bridge_allows_optimization(peer_bridge)) {
3036 }
3037
3038 switch (bridges_allow_swap_optimization(chan_bridge, peer_bridge)) {
3043 case SWAP_PROHIBITED:
3044 default:
3045 break;
3046 }
3047
3048 /* Two channels will be kicked from the bridges, the unreal;1 and unreal;2 channels */
3049 if (bridges_allow_merge_optimization(chan_bridge, peer_bridge, 2, &merge) != MERGE_ALLOWED) {
3051 }
3052
3053 if (merge.dest == chan_bridge) {
3055 } else {
3057 }
3058}
static enum bridge_allow_merge bridges_allow_merge_optimization(struct ast_bridge *chan_bridge, struct ast_bridge *peer_bridge, int num_kick_channels, struct merge_direction *merge)
Definition: bridge.c:2904
@ SWAP_PROHIBITED
Definition: bridge.c:2743
@ SWAP_TO_PEER_BRIDGE
Definition: bridge.c:2747
@ SWAP_TO_CHAN_BRIDGE
Definition: bridge.c:2745
@ MERGE_ALLOWED
Definition: bridge.c:2888
static enum bridge_allow_swap bridges_allow_swap_optimization(struct ast_bridge *chan_bridge, struct ast_bridge *peer_bridge)
Definition: bridge.c:2758
static int bridge_allows_optimization(struct ast_bridge *bridge)
Definition: bridge.c:2629

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, bridge_allows_optimization(), bridges_allow_merge_optimization(), bridges_allow_swap_optimization(), merge_direction::dest, MERGE_ALLOWED, SWAP_PROHIBITED, SWAP_TO_CHAN_BRIDGE, and SWAP_TO_PEER_BRIDGE.

Referenced by two_bridge_attended_transfer().

◆ ast_brige_set_remb_behavior()

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 3867 of file bridge.c.

3868{
3870
3871 ast_bridge_lock(bridge);
3873 ast_bridge_unlock(bridge);
3874}
enum ast_bridge_video_sfu_remb_behavior remb_behavior
Definition: bridge.h:157

References ast_assert, ast_bridge_lock, ast_bridge_unlock, AST_BRIDGE_VIDEO_MODE_SFU, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_sfu_data::remb_behavior, ast_bridge_video_mode::sfu_data, ast_bridge::softmix, and ast_bridge_softmix::video_mode.

Referenced by join_conference_bridge().

Variable Documentation

◆ ast_bridge_base_v_table

struct ast_bridge_methods ast_bridge_base_v_table
extern