Asterisk - The Open Source Telephony Project  18.5.0
Functions
bridge_internal.h File Reference

Private Bridging API. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct ast_bridgebridge_alloc (size_t size, const struct ast_bridge_methods *v_table)
 
struct ast_bridgebridge_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. More...
 
void bridge_dissolve (struct ast_bridge *bridge, int cause)
 
void bridge_do_merge (struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_bridge_channel **kick_me, unsigned int num_kick, unsigned int optimized)
 
int bridge_do_move (struct ast_bridge *dst_bridge, struct ast_bridge_channel *bridge_channel, int attempt_recovery, unsigned int optimized)
 
struct ast_bridge_channelbridge_find_channel (struct ast_bridge *bridge, struct ast_channel *chan)
 
void bridge_merge_inhibit_nolock (struct ast_bridge *bridge, int request)
 
void bridge_reconfigured (struct ast_bridge *bridge, unsigned int colp_update)
 
struct ast_bridgebridge_register (struct ast_bridge *bridge)
 Register the new bridge with the system. More...
 

Detailed Description

Private Bridging API.

Functions in this file are intended to be used by the Bridging API, bridge mixing technologies, and bridge sub-classes. Users of bridges that do not fit those three categories should not use the API defined in this file.

Author
Mark Michelson mmich.nosp@m.elso.nosp@m.n@dig.nosp@m.ium..nosp@m.com

See Also:

Definition in file bridge_internal.h.

Function Documentation

◆ bridge_alloc()

struct ast_bridge* bridge_alloc ( size_t  size,
const struct ast_bridge_methods v_table 
)

Definition at line 724 of file bridge.c.

References ao2_alloc, ao2_cleanup, ast_assert, ast_log, AST_MEDIA_TYPE_END, ast_string_field_init, AST_VECTOR_INIT, bridge_manager_request::bridge, ast_bridge_methods::destroy, destroy_bridge(), ast_bridge_methods::dissolving, ast_bridge_methods::get_merge_priority, LOG_ERROR, ast_bridge::media_types, ast_bridge_methods::name, ast_bridge_methods::notify_masquerade, NULL, ast_bridge_methods::pull, ast_bridge_methods::push, and ast_bridge::v_table.

Referenced by ast_bridge_base_new(), ast_bridge_basic_new(), bridge_agent_hold_new(), bridge_parking_new(), and bridge_stasis_new().

725 {
726  struct ast_bridge *bridge;
727 
728  /* Check v_table that all methods are present. */
729  if (!v_table
730  || !v_table->name
731  || !v_table->destroy
732  || !v_table->dissolving
733  || !v_table->push
734  || !v_table->pull
735  || !v_table->notify_masquerade
736  || !v_table->get_merge_priority) {
737  ast_log(LOG_ERROR, "Virtual method table for bridge class %s not complete.\n",
738  v_table && v_table->name ? v_table->name : "<unknown>");
739  ast_assert(0);
740  return NULL;
741  }
742 
743  bridge = ao2_alloc(size, destroy_bridge);
744  if (!bridge) {
745  return NULL;
746  }
747 
748  if (ast_string_field_init(bridge, 80)) {
749  ao2_cleanup(bridge);
750  return NULL;
751  }
752 
753  bridge->v_table = v_table;
754 
756 
757  return bridge;
758 }
static void destroy_bridge(void *obj)
Definition: bridge.c:658
const char * name
Definition: bridge.h:267
ast_bridge_dissolving_fn dissolving
Definition: bridge.h:271
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
ast_bridge_notify_masquerade_fn notify_masquerade
Definition: bridge.h:277
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
const struct ast_bridge_methods * v_table
Definition: bridge.h:359
Structure that contains information about a bridge.
Definition: bridge.h:357
#define LOG_ERROR
Definition: logger.h:285
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
ast_bridge_merge_priority_fn get_merge_priority
Definition: bridge.h:279
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct ast_vector_int media_types
Definition: bridge.h:412
ast_bridge_pull_channel_fn pull
Definition: bridge.h:275
ast_bridge_destructor_fn destroy
Definition: bridge.h:269
ast_bridge_push_channel_fn push
Definition: bridge.h:273

◆ bridge_base_init()

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.

Parameters
selfBridge to operate upon. (Tolerates a NULL pointer)
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)
Return values
selfon success
NULLon failure, self is already destroyed

Example usage:

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

Definition at line 760 of file bridge.c.

References ao2_ref, AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic(), ast_debug, ast_log, ast_set_flag, ast_string_field_set, ast_strlen_zero, ast_tvnow(), ast_uuid_generate_str(), AST_UUID_STR_LEN, bridge_topics_init(), find_best_technology(), LOG_WARNING, NULL, and ast_bridge::uniqueid.

Referenced by ast_bridge_base_new(), ast_bridge_basic_new(), bridge_agent_hold_new(), bridge_parking_new(), and bridge_stasis_new().

761 {
762  char uuid_hold[AST_UUID_STR_LEN];
763 
764  if (!self) {
765  return NULL;
766  }
767 
768  if (!ast_strlen_zero(id)) {
769  ast_string_field_set(self, uniqueid, id);
770  } else {
772  ast_string_field_set(self, uniqueid, uuid_hold);
773  }
775  if (!ast_strlen_zero(creator)) {
777  }
778 
779  ast_set_flag(&self->feature_flags, flags);
780  self->allowed_capabilities = capabilities;
781 
782  if (!(flags & AST_BRIDGE_FLAG_INVISIBLE)) {
783  if (bridge_topics_init(self) != 0) {
784  ast_log(LOG_WARNING, "Bridge %s: Could not initialize topics\n",
785  self->uniqueid);
786  ao2_ref(self, -1);
787  return NULL;
788  }
789  }
790 
791  /* Use our helper function to find the "best" bridge technology. */
792  self->technology = find_best_technology(capabilities, self);
793  if (!self->technology) {
794  ast_log(LOG_WARNING, "Bridge %s: Could not create class %s. No technology to support it.\n",
795  self->uniqueid, self->v_table->name);
796  ao2_ref(self, -1);
797  return NULL;
798  }
799 
800  /* Pass off the bridge to the technology to manipulate if needed */
801  ast_debug(1, "Bridge %s: calling %s technology constructor\n",
802  self->uniqueid, self->technology->name);
803  if (self->technology->create && self->technology->create(self)) {
804  ast_log(LOG_WARNING, "Bridge %s: failed to setup bridge technology %s\n",
805  self->uniqueid, self->technology->name);
806  ao2_ref(self, -1);
807  return NULL;
808  }
809  ast_debug(1, "Bridge %s: calling %s technology start\n",
810  self->uniqueid, self->technology->name);
811  if (self->technology->start && self->technology->start(self)) {
812  ast_log(LOG_WARNING, "Bridge %s: failed to start bridge technology %s\n",
813  self->uniqueid, self->technology->name);
814  ao2_ref(self, -1);
815  return NULL;
816  }
817 
818  if (!(flags & AST_BRIDGE_FLAG_INVISIBLE)) {
819  if (!ast_bridge_topic(self)) {
820  ao2_ref(self, -1);
821  return NULL;
822  }
823  }
824 
825  self->creationtime = ast_tvnow();
826 
827  return self;
828 }
struct ast_flags feature_flags
Definition: bridge.h:377
const ast_string_field uniqueid
Definition: bridge.h:409
#define AST_UUID_STR_LEN
Definition: uuid.h:27
const char * name
Definition: bridge.h:267
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:274
int(* start)(struct ast_bridge *bridge)
Request a bridge technology instance start operations.
int bridge_topics_init(struct ast_bridge *bridge)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
static struct ast_bridge_technology * find_best_technology(uint32_t capabilities, struct ast_bridge *bridge)
Helper function used to find the "best" bridge technology given specified capabilities.
Definition: bridge.c:511
struct ast_bridge_technology * technology
Definition: bridge.h:363
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const struct ast_bridge_methods * v_table
Definition: bridge.h:359
static const char name[]
Definition: cdr_mysql.c:74
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
Definition: uuid.c:143
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
int(* create)(struct ast_bridge *bridge)
Create a bridge technology instance for a bridge.
const ast_string_field creator
Definition: bridge.h:409
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ bridge_dissolve()

void bridge_dissolve ( struct ast_bridge bridge,
int  cause 
)

Definition at line 319 of file bridge.c.

References ast_bridge_channel_leave_bridge(), ast_bridge_queue_action(), ast_cause2str(), AST_CAUSE_NORMAL_CLEARING, ast_debug, AST_FRAME_BRIDGE_ACTION, AST_LIST_TRAVERSE, BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, ast_bridge::cause, ast_bridge::channels, ast_bridge::dissolved, ast_frame::frametype, and ast_bridge::uniqueid.

Referenced by ast_bridge_destroy(), bridge_channel_dissolve_check(), bridge_dissolve_check_stolen(), and bridge_reconfigured().

320 {
321  struct ast_bridge_channel *bridge_channel;
322  struct ast_frame action = {
324  .subclass.integer = BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING,
325  };
326 
327  if (bridge->dissolved) {
328  return;
329  }
330  bridge->dissolved = 1;
331 
332  if (cause <= 0) {
334  }
335  bridge->cause = cause;
336 
337  ast_debug(1, "Bridge %s: dissolving bridge with cause %d(%s)\n",
338  bridge->uniqueid, cause, ast_cause2str(cause));
339 
340  AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
341  ast_bridge_channel_leave_bridge(bridge_channel,
343  }
344 
345  /* Must defer dissolving bridge because it is already locked. */
346  ast_bridge_queue_action(bridge, &action);
347 }
const ast_string_field uniqueid
Definition: bridge.h:409
unsigned int dissolved
Definition: bridge.h:398
int ast_bridge_queue_action(struct ast_bridge *bridge, struct ast_frame *action)
Put an action onto the specified bridge.
Definition: bridge.c:307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
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_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:612
int cause
Definition: bridge.h:394
struct ast_bridge_channels_list channels
Definition: bridge.h:371
Structure that contains information regarding a channel in a bridge.
Data structure associated with a single frame of data.
Definition: search.h:40
enum ast_frame_type frametype

◆ bridge_do_merge()

void bridge_do_merge ( struct ast_bridge dst_bridge,
struct ast_bridge src_bridge,
struct ast_bridge_channel **  kick_me,
unsigned int  num_kick,
unsigned int  optimized 
)

Definition at line 2096 of file bridge.c.

References AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE, ast_bridge_channel_leave_bridge(), ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_bridge_features_remove(), AST_BRIDGE_HOOK_REMOVE_ON_PULL, ast_bridge_publish_merge(), AST_CAUSE_NORMAL_CLEARING, ast_debug, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_test_flag, ast_bridge_channel::bridge, bridge_channel_change_bridge(), bridge_channel_internal_pull(), bridge_channel_internal_push(), bridge_channel_moving(), BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, BRIDGE_CHANNEL_STATE_WAIT, bridge_reconfigured(), ast_bridge::cause, ast_bridge::channels, ast_bridge_features::feature_flags, ast_bridge_channel::features, ast_bridge_channel::state, and ast_bridge::uniqueid.

Referenced by bridge_merge(), bridge_merge_locked(), try_merge_optimize_out(), and two_bridge_attended_transfer().

2098 {
2099  struct ast_bridge_channel *bridge_channel;
2100  unsigned int idx;
2101 
2102  ast_debug(1, "Merging bridge %s into bridge %s\n",
2103  src_bridge->uniqueid, dst_bridge->uniqueid);
2104 
2105  ast_bridge_publish_merge(dst_bridge, src_bridge);
2106 
2107  /*
2108  * Move channels from src_bridge over to dst_bridge.
2109  *
2110  * We must use AST_LIST_TRAVERSE_SAFE_BEGIN() because
2111  * bridge_channel_internal_pull() alters the list we are traversing.
2112  */
2113  AST_LIST_TRAVERSE_SAFE_BEGIN(&src_bridge->channels, bridge_channel, entry) {
2114  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
2115  /*
2116  * The channel is already leaving let it leave normally because
2117  * pulling it may delete hooks that should run for this channel.
2118  */
2119  continue;
2120  }
2121  if (ast_test_flag(&bridge_channel->features->feature_flags,
2123  continue;
2124  }
2125 
2126  if (kick_me) {
2127  for (idx = 0; idx < num_kick; ++idx) {
2128  if (bridge_channel == kick_me[idx]) {
2129  ast_bridge_channel_leave_bridge(bridge_channel,
2131  break;
2132  }
2133  }
2134  }
2135  bridge_channel_internal_pull(bridge_channel);
2136  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
2137  /*
2138  * The channel died as a result of being pulled or it was
2139  * kicked. Leave it pointing to the original bridge.
2140  */
2141  continue;
2142  }
2143 
2144  bridge_channel_moving(bridge_channel, bridge_channel->bridge, dst_bridge);
2145 
2146  /* Point to new bridge.*/
2147  bridge_channel_change_bridge(bridge_channel, dst_bridge);
2148 
2149  if (bridge_channel_internal_push(bridge_channel)) {
2150  ast_bridge_features_remove(bridge_channel->features,
2152  ast_bridge_channel_leave_bridge(bridge_channel,
2154  }
2155  }
2157 
2158  if (kick_me) {
2159  /*
2160  * Now we can kick any channels in the dst_bridge without
2161  * potentially dissolving the bridge.
2162  */
2163  for (idx = 0; idx < num_kick; ++idx) {
2164  bridge_channel = kick_me[idx];
2165  ast_bridge_channel_lock(bridge_channel);
2166  if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
2169  bridge_channel_internal_pull(bridge_channel);
2170  }
2171  ast_bridge_channel_unlock(bridge_channel);
2172  }
2173  }
2174 
2175  bridge_reconfigured(dst_bridge, !optimized);
2176  bridge_reconfigured(src_bridge, !optimized);
2177 
2178  ast_debug(1, "Merged bridge %s into bridge %s\n",
2179  src_bridge->uniqueid, dst_bridge->uniqueid);
2180 }
const ast_string_field uniqueid
Definition: bridge.h:409
struct ast_bridge_features * features
static void bridge_channel_change_bridge(struct ast_bridge_channel *bridge_channel, struct ast_bridge *new_bridge)
Definition: bridge.c:2055
void ast_bridge_channel_leave_bridge_nolock(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_test_flag(p, flag)
Definition: utils.h:63
enum bridge_channel_state state
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_flags feature_flags
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
static void bridge_channel_moving(struct ast_bridge_channel *bridge_channel, struct ast_bridge *src, struct ast_bridge *dst)
Definition: bridge.c:2070
void bridge_reconfigured(struct ast_bridge *bridge, unsigned int colp_update)
Definition: bridge.c:1443
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).
int cause
Definition: bridge.h:394
int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel)
struct ast_bridge_channels_list channels
Definition: bridge.h:371
Structure that contains information regarding a channel in a bridge.
void ast_bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags remove_flags)
Remove marked bridge channel feature hooks.
Definition: bridge.c:3568
Definition: search.h:40
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel)
void ast_bridge_publish_merge(struct ast_bridge *to, struct ast_bridge *from)
Publish a bridge merge.

◆ bridge_do_move()

int bridge_do_move ( struct ast_bridge dst_bridge,
struct ast_bridge_channel bridge_channel,
int  attempt_recovery,
unsigned int  optimized 
)

Definition at line 2362 of file bridge.c.

References ao2_ref, ast_bridge_channel_leave_bridge(), ast_bridge_features_remove(), AST_BRIDGE_HOOK_REMOVE_ON_PULL, ast_channel_name(), ast_debug, ast_bridge_channel::bridge, bridge_channel_change_bridge(), bridge_channel_internal_pull(), bridge_channel_internal_push(), bridge_channel_internal_push_full(), bridge_channel_moving(), bridge_channel_settle_owed_events(), BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, BRIDGE_CHANNEL_STATE_WAIT, bridge_reconfigured(), ast_bridge::cause, ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_channel::in_bridge, NULL, ast_bridge_channel::state, ast_bridge_channel::swap, and ast_bridge::uniqueid.

Referenced by bridge_move(), bridge_move_locked(), bridge_swap_attended_transfer(), and try_swap_optimize_out().

2364 {
2365  struct ast_bridge *orig_bridge;
2366  int was_in_bridge;
2367  int res = 0;
2368 
2369  if (bridge_channel->swap) {
2370  ast_debug(1, "Moving %p(%s) into bridge %s swapping with %s\n",
2371  bridge_channel, ast_channel_name(bridge_channel->chan), dst_bridge->uniqueid,
2372  ast_channel_name(bridge_channel->swap));
2373  } else {
2374  ast_debug(1, "Moving %p(%s) into bridge %s\n",
2375  bridge_channel, ast_channel_name(bridge_channel->chan), dst_bridge->uniqueid);
2376  }
2377 
2378  orig_bridge = bridge_channel->bridge;
2379  was_in_bridge = bridge_channel->in_bridge;
2380 
2381  bridge_channel_internal_pull(bridge_channel);
2382  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
2383  /*
2384  * The channel died as a result of being pulled. Leave it
2385  * pointing to the original bridge.
2386  *
2387  * Clear out the swap channel pointer. A ref is not held
2388  * by bridge_channel->swap at this point.
2389  */
2390  bridge_channel->swap = NULL;
2391  bridge_reconfigured(orig_bridge, 0);
2392  return -1;
2393  }
2394 
2395  /* Point to new bridge.*/
2396  ao2_ref(orig_bridge, +1);/* Keep a ref in case the push fails. */
2397  bridge_channel_change_bridge(bridge_channel, dst_bridge);
2398 
2399  bridge_channel_moving(bridge_channel, orig_bridge, dst_bridge);
2400 
2401  if (bridge_channel_internal_push_full(bridge_channel, optimized)) {
2402  /* Try to put the channel back into the original bridge. */
2403  ast_bridge_features_remove(bridge_channel->features,
2405  if (attempt_recovery && was_in_bridge) {
2406  /* Point back to original bridge. */
2407  bridge_channel_change_bridge(bridge_channel, orig_bridge);
2408 
2409  if (bridge_channel_internal_push(bridge_channel)) {
2410  ast_bridge_features_remove(bridge_channel->features,
2412  ast_bridge_channel_leave_bridge(bridge_channel,
2414  }
2415  } else {
2416  ast_bridge_channel_leave_bridge(bridge_channel,
2418  bridge_channel_settle_owed_events(orig_bridge, bridge_channel);
2419  }
2420  res = -1;
2421  } else if (!optimized) {
2422  bridge_channel_settle_owed_events(orig_bridge, bridge_channel);
2423  }
2424 
2425  bridge_reconfigured(dst_bridge, !optimized);
2426  bridge_reconfigured(orig_bridge, !optimized);
2427  ao2_ref(orig_bridge, -1);
2428  return res;
2429 }
const ast_string_field uniqueid
Definition: bridge.h:409
struct ast_bridge_features * features
static void bridge_channel_change_bridge(struct ast_bridge_channel *bridge_channel, struct ast_bridge *new_bridge)
Definition: bridge.c:2055
enum bridge_channel_state state
#define NULL
Definition: resample.c:96
void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel)
struct ast_bridge * bridge
Bridge this channel is participating in.
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static void bridge_channel_moving(struct ast_bridge_channel *bridge_channel, struct ast_bridge *src, struct ast_bridge *dst)
Definition: bridge.c:2070
Structure that contains information about a bridge.
Definition: bridge.h:357
int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel, int optimized)
void bridge_reconfigured(struct ast_bridge *bridge, unsigned int colp_update)
Definition: bridge.c:1443
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).
unsigned int in_bridge
struct ast_channel * swap
int cause
Definition: bridge.h:394
int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel)
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
void ast_bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags remove_flags)
Remove marked bridge channel feature hooks.
Definition: bridge.c:3568
void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel)

◆ bridge_find_channel()

struct ast_bridge_channel* bridge_find_channel ( struct ast_bridge bridge,
struct ast_channel chan 
)

Definition at line 1469 of file bridge.c.

References AST_LIST_TRAVERSE, ast_bridge_channel::chan, and ast_bridge::channels.

Referenced by ast_bridge_add_channel(), ast_bridge_join(), ast_bridge_kick(), ast_bridge_notify_masquerade(), ast_bridge_remove(), ast_bridge_suspend(), ast_bridge_unsuspend(), bridge_channel_internal_push_full(), bridge_impart_internal(), bridge_merge(), bridge_merge_locked(), bridge_move_locked(), and play_uri().

1470 {
1471  struct ast_bridge_channel *bridge_channel;
1472 
1473  AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
1474  if (bridge_channel->chan == chan) {
1475  break;
1476  }
1477  }
1478 
1479  return bridge_channel;
1480 }
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_bridge_channels_list channels
Definition: bridge.h:371
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
Definition: search.h:40

◆ bridge_merge_inhibit_nolock()

void bridge_merge_inhibit_nolock ( struct ast_bridge bridge,
int  request 
)

Definition at line 3052 of file bridge.c.

References ast_assert, ast_bridge::inhibit_merge, and request().

Referenced by ast_bridge_channel_merge_inhibit(), and ast_bridge_merge_inhibit().

3053 {
3054  int new_request;
3055 
3056  new_request = bridge->inhibit_merge + request;
3057  ast_assert(0 <= new_request);
3058  bridge->inhibit_merge = new_request;
3059 }
unsigned int inhibit_merge
Count of the active temporary requests to inhibit bridge merges. Zero if merges are allowed...
Definition: bridge.h:392
#define ast_assert(a)
Definition: utils.h:695
static int request(void *obj)
Definition: chan_pjsip.c:2559

◆ bridge_reconfigured()

void bridge_reconfigured ( struct ast_bridge bridge,
unsigned int  colp_update 
)

Definition at line 1443 of file bridge.c.

References AST_BRIDGE_FLAG_SMART, ast_bridge_publish_state(), ast_test_flag, bridge_complete_join(), bridge_dissolve(), bridge_reconfigured_connected_line_update(), check_bridge_play_sounds(), ast_bridge::dissolved, ast_bridge::feature_flags, ast_bridge::reconfigured, set_bridge_peer_vars(), and smart_bridge_operation().

Referenced by ast_bridge_notify_masquerade(), bridge_channel_handle_control(), bridge_channel_internal_join(), bridge_channel_wait(), bridge_do_merge(), and bridge_do_move().

1444 {
1445  if (!bridge->reconfigured) {
1446  return;
1447  }
1448  bridge->reconfigured = 0;
1450  && smart_bridge_operation(bridge)) {
1451  /* Smart bridge failed. */
1452  bridge_dissolve(bridge, 0);
1453  return;
1454  }
1455  bridge_complete_join(bridge);
1456 
1457  if (bridge->dissolved) {
1458  return;
1459  }
1460  check_bridge_play_sounds(bridge);
1461  set_bridge_peer_vars(bridge);
1462  ast_bridge_publish_state(bridge);
1463 
1464  if (colp_update) {
1466  }
1467 }
struct ast_flags feature_flags
Definition: bridge.h:377
static void check_bridge_play_sounds(struct ast_bridge *bridge)
Definition: bridge.c:1233
#define ast_test_flag(p, flag)
Definition: utils.h:63
unsigned int dissolved
Definition: bridge.h:398
unsigned int reconfigured
Definition: bridge.h:396
static void set_bridge_peer_vars(struct ast_bridge *bridge)
Definition: bridge.c:1426
void bridge_dissolve(struct ast_bridge *bridge, int cause)
Definition: bridge.c:319
static void bridge_reconfigured_connected_line_update(struct ast_bridge *bridge)
Definition: bridge.c:393
void ast_bridge_publish_state(struct ast_bridge *bridge)
Publish the state of a bridge.
static int smart_bridge_operation(struct ast_bridge *bridge)
Definition: bridge.c:998
static void bridge_complete_join(struct ast_bridge *bridge)
Definition: bridge.c:486

◆ bridge_register()

struct ast_bridge* bridge_register ( struct ast_bridge bridge)

Register the new bridge with the system.

Since
12.0.0
Parameters
bridgeWhat to register. (Tolerates a NULL pointer)
struct ast_bridge *ast_bridge_basic_new(uint32_t capabilities, int flags, uint32 dtmf_features)
{
void *bridge;
bridge = bridge_alloc(sizeof(struct ast_bridge_basic), &ast_bridge_basic_v_table);
bridge = bridge_base_init(bridge, capabilities, flags);
bridge = ast_bridge_basic_init(bridge, dtmf_features);
bridge = bridge_register(bridge);
return bridge;
}
Note
This must be done after a bridge constructor has completed setting up the new bridge but before it returns.
After a bridge is registered, ast_bridge_destroy() must eventually be called to get rid of the bridge.
Return values
bridgeon success.
NULLon error.

Definition at line 709 of file bridge.c.

References ao2_link, ast_bridge_destroy(), ast_bridge_lock, ast_bridge_publish_state(), ast_bridge_unlock, bridge_manager_request::bridge, ast_bridge::construction_completed, and NULL.

Referenced by ast_bridge_base_new(), ast_bridge_basic_new(), bridge_agent_hold_new(), bridge_parking_new(), and bridge_stasis_new().

710 {
711  if (bridge) {
712  bridge->construction_completed = 1;
713  ast_bridge_lock(bridge);
714  ast_bridge_publish_state(bridge);
715  ast_bridge_unlock(bridge);
716  if (!ao2_link(bridges, bridge)) {
717  ast_bridge_destroy(bridge, 0);
718  bridge = NULL;
719  }
720  }
721  return bridge;
722 }
#define NULL
Definition: resample.c:96
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
Definition: bridge.c:970
void ast_bridge_publish_state(struct ast_bridge *bridge)
Publish the state of a bridge.
static struct ao2_container * bridges
Definition: bridge.c:123
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:493
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:480
unsigned int construction_completed
Definition: bridge.h:400
#define ao2_link(container, obj)
Definition: astobj2.h:1549