Asterisk - The Open Source Telephony Project GIT-master-6144b6b
Loading...
Searching...
No Matches
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.
 
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.
 

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

766{
767 struct ast_bridge *bridge;
768
769 /* Check v_table that all methods are present. */
770 if (!v_table
771 || !v_table->name
772 || !v_table->destroy
774 || !v_table->push
775 || !v_table->pull
778 ast_log(LOG_ERROR, "Virtual method table for bridge class %s not complete.\n",
779 v_table && v_table->name ? v_table->name : "<unknown>");
780 ast_assert(0);
781 return NULL;
782 }
783
784 bridge = ao2_alloc(size, destroy_bridge);
785 if (!bridge) {
786 return NULL;
787 }
788
789 if (ast_string_field_init(bridge, 80)) {
790 ao2_cleanup(bridge);
791 return NULL;
792 }
793
794 bridge->v_table = v_table;
795
799
800 return bridge;
801}
#define ast_log
Definition astobj2.c:42
#define ao2_cleanup(obj)
Definition astobj2.h:1934
#define ao2_alloc(data_size, destructor_fn)
Definition astobj2.h:409
static void destroy_bridge(void *obj)
Definition bridge.c:670
@ AST_MEDIA_TYPE_END
Definition codec.h:36
#define LOG_ERROR
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define NULL
Definition resample.c:96
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
ast_bridge_dissolving_fn dissolving
Definition bridge.h:267
ast_bridge_push_channel_fn push
Definition bridge.h:269
const char * name
Definition bridge.h:263
ast_bridge_notify_masquerade_fn notify_masquerade
Definition bridge.h:273
ast_bridge_destructor_fn destroy
Definition bridge.h:265
ast_bridge_merge_priority_fn get_merge_priority
Definition bridge.h:275
ast_bridge_pull_channel_fn pull
Definition bridge.h:271
Structure that contains information about a bridge.
Definition bridge.h:355
struct ast_vector_int media_types
Definition bridge.h:410
const struct ast_bridge_methods * v_table
Definition bridge.h:357
struct varshead bridgevars
Definition bridge.h:416
struct ast_bridge::@200 ari_reportable_variable_names
#define ast_assert(a)
Definition utils.h:779
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition vector.h:124

References ao2_alloc, ao2_cleanup, ast_bridge::ari_reportable_variable_names, ast_assert, AST_LIST_HEAD_INIT_NOLOCK, ast_log, AST_MEDIA_TYPE_END, ast_string_field_init, AST_VECTOR_INIT, ast_bridge::bridgevars, 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().

◆ 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)
Returns
self on success
Return values
NULLon failure, self is already destroyed

Example usage:

struct ast_bridge *bridge;
bridge = bridge_alloc(sizeof(*bridge), &ast_bridge_base_v_table);
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
Definition bridge.c:1008
@ AST_BRIDGE_CAPABILITY_1TO1MIX
Definition bridge.h:96
@ AST_BRIDGE_FLAG_DISSOLVE_HANGUP
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:803
struct ast_bridge * bridge_alloc(size_t size, const struct ast_bridge_methods *v_table)
Definition bridge.c:765

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

Definition at line 803 of file bridge.c.

804{
805 char uuid_hold[AST_UUID_STR_LEN];
806
807 if (!self) {
808 return NULL;
809 }
810
811 {
812 /*
813 * We need to ensure that another bridge with the same uniqueid
814 * doesn't get created before the previous bridge's destructor
815 * has run and deleted the existing topic.
816 */
818 if (!ast_strlen_zero(id)) {
819 if (ast_bridge_topic_exists(id)) {
820 ast_log(LOG_WARNING, "Bridge " BRIDGE_PRINTF_SPEC ": already registered\n",
821 BRIDGE_PRINTF_VARS(self));
822 ast_bridge_destroy(self, 0);
823 return NULL;
824 }
825 ast_string_field_set(self, uniqueid, id);
826 } else {
828 ast_string_field_set(self, uniqueid, uuid_hold);
829 }
830 if (!(flags & AST_BRIDGE_FLAG_INVISIBLE)) {
831 if (bridge_topics_init(self) != 0) {
832 ast_log(LOG_WARNING, "Bridge " BRIDGE_PRINTF_SPEC ": Could not initialize topics\n",
833 BRIDGE_PRINTF_VARS(self));
834 ao2_ref(self, -1);
835 return NULL;
836 }
837 }
838 }
839
840 ast_string_field_set(self, creator, creator);
841 if (!ast_strlen_zero(creator)) {
843 }
844 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": base_init\n",
845 BRIDGE_PRINTF_VARS(self));
846
847 ast_set_flag(&self->feature_flags, flags);
848 self->allowed_capabilities = capabilities;
849
850 /* Use our helper function to find the "best" bridge technology. */
851 self->technology = find_best_technology(capabilities, self);
852 if (!self->technology) {
853 ast_log(LOG_WARNING, "Bridge %s: Could not create class %s. No technology to support it.\n",
854 self->uniqueid, self->v_table->name);
855 ao2_ref(self, -1);
856 return NULL;
857 }
858
859 /* Pass off the bridge to the technology to manipulate if needed */
860 ast_debug(1, "Bridge %s: calling %s technology constructor\n",
861 self->uniqueid, self->technology->name);
862 if (self->technology->create && self->technology->create(self)) {
863 ast_log(LOG_WARNING, "Bridge %s: failed to setup bridge technology %s\n",
864 self->uniqueid, self->technology->name);
865 ao2_ref(self, -1);
866 return NULL;
867 }
868 ast_debug(1, "Bridge %s: calling %s technology start\n",
869 self->uniqueid, self->technology->name);
870 if (self->technology->start && self->technology->start(self)) {
871 ast_log(LOG_WARNING, "Bridge %s: failed to start bridge technology %s\n",
872 self->uniqueid, self->technology->name);
873 ao2_ref(self, -1);
874 return NULL;
875 }
876
877 if (!(flags & AST_BRIDGE_FLAG_INVISIBLE)) {
878 if (!ast_bridge_topic(self)) {
879 ao2_ref(self, -1);
880 return NULL;
881 }
882 }
883
884 self->creationtime = ast_tvnow();
885 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": base_init complete\n",
886 BRIDGE_PRINTF_VARS(self));
887
888 return self;
889}
ast_mutex_t lock
Definition app_sla.c:337
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
Definition bridge.c:1029
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:529
static ast_mutex_t bridge_init_lock
Definition bridge.c:136
#define BRIDGE_PRINTF_VARS(bridge)
Definition bridge.h:80
#define BRIDGE_PRINTF_SPEC
Definition bridge.h:79
@ AST_BRIDGE_FLAG_INVISIBLE
static const char name[]
Definition format_mp3.c:68
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
Definition lock.h:596
int ast_bridge_topic_exists(const char *uniqueid)
Check if a stasis topic exists for a bridge uniqueid.
int bridge_topics_init(struct ast_bridge *bridge)
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
int(* start)(struct ast_bridge *bridge)
Request a bridge technology instance start operations.
int(* create)(struct ast_bridge *bridge)
Create a bridge technology instance for a bridge.
struct timeval creationtime
Definition bridge.h:414
const ast_string_field uniqueid
Definition bridge.h:407
struct ast_bridge_technology * technology
Definition bridge.h:361
struct ast_flags feature_flags
Definition bridge.h:375
uint32_t allowed_capabilities
Definition bridge.h:377
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition time.h:159
#define ast_set_flag(p, flag)
Definition utils.h:71
#define AST_UUID_STR_LEN
Definition uuid.h:27
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
Definition uuid.c:141

References ast_bridge::allowed_capabilities, ao2_ref, ast_bridge_destroy(), AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic(), ast_bridge_topic_exists(), 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_init_lock, BRIDGE_PRINTF_SPEC, BRIDGE_PRINTF_VARS, bridge_topics_init(), ast_bridge_technology::create, ast_bridge::creationtime, ast_bridge::creator, ast_bridge::feature_flags, find_best_technology(), lock, LOG_WARNING, name, ast_bridge_methods::name, ast_bridge_technology::name, NULL, SCOPED_MUTEX, ast_bridge_technology::start, ast_bridge::technology, ast_bridge::uniqueid, 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().

◆ bridge_dissolve()

void bridge_dissolve ( struct ast_bridge bridge,
int  cause 
)

Definition at line 337 of file bridge.c.

338{
339 struct ast_bridge_channel *bridge_channel;
340 struct ast_frame action = {
343 };
344
345 if (bridge->dissolved) {
346 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": already dissolved\n",
347 BRIDGE_PRINTF_VARS(bridge));
348 return;
349 }
350 bridge->dissolved = 1;
351
352 if (cause <= 0) {
354 }
355 bridge->cause = cause;
356
357 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": dissolving with cause %d(%s)\n",
358 BRIDGE_PRINTF_VARS(bridge), cause, ast_cause2str(cause));
359
360 AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
361 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": kicking channel %s\n",
362 BRIDGE_PRINTF_VARS(bridge),
363 ast_channel_name(bridge_channel->chan));
364 ast_bridge_channel_leave_bridge(bridge_channel,
366 }
367
368 /* Must defer dissolving bridge because it is already locked. */
369 ast_bridge_queue_action(bridge, &action);
370 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": DEFERRED_DISSOLVING queued. current refcound: %d\n",
371 BRIDGE_PRINTF_VARS(bridge), ao2_ref(bridge, 0));
372
373}
int ast_bridge_queue_action(struct ast_bridge *bridge, struct ast_frame *action)
Put an action onto the specified bridge.
Definition bridge.c:325
@ 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).
@ BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING
#define AST_CAUSE_NORMAL_CLEARING
Definition causes.h:106
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
Definition channel.c:613
@ AST_FRAME_BRIDGE_ACTION
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
struct ast_bridge_channels_list channels
Definition bridge.h:369
unsigned int dissolved
Definition bridge.h:396
int cause
Definition bridge.h:392
Data structure associated with a single frame of data.
enum ast_frame_type frametype

References ao2_ref, ast_bridge_channel_leave_bridge(), ast_bridge_queue_action(), ast_cause2str(), AST_CAUSE_NORMAL_CLEARING, ast_channel_name(), ast_debug, AST_FRAME_BRIDGE_ACTION, AST_LIST_TRAVERSE, BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, BRIDGE_PRINTF_SPEC, BRIDGE_PRINTF_VARS, ast_bridge::cause, ast_bridge_channel::chan, ast_bridge::channels, ast_bridge::dissolved, and ast_frame::frametype.

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

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

2249{
2250 struct ast_bridge_channel *bridge_channel;
2251 unsigned int idx;
2252
2253 ast_debug(1, "Merging bridge %s into bridge %s\n",
2254 src_bridge->uniqueid, dst_bridge->uniqueid);
2255
2256 ast_bridge_publish_merge(dst_bridge, src_bridge);
2257
2258 /*
2259 * Move channels from src_bridge over to dst_bridge.
2260 *
2261 * We must use AST_LIST_TRAVERSE_SAFE_BEGIN() because
2262 * bridge_channel_internal_pull() alters the list we are traversing.
2263 */
2264 AST_LIST_TRAVERSE_SAFE_BEGIN(&src_bridge->channels, bridge_channel, entry) {
2265 if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
2266 /*
2267 * The channel is already leaving let it leave normally because
2268 * pulling it may delete hooks that should run for this channel.
2269 */
2270 continue;
2271 }
2272 if (ast_test_flag(&bridge_channel->features->feature_flags,
2274 continue;
2275 }
2276
2277 if (kick_me) {
2278 for (idx = 0; idx < num_kick; ++idx) {
2279 if (bridge_channel == kick_me[idx]) {
2280 ast_bridge_channel_leave_bridge(bridge_channel,
2282 break;
2283 }
2284 }
2285 }
2286 bridge_channel_internal_pull(bridge_channel);
2287 if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
2288 /*
2289 * The channel died as a result of being pulled or it was
2290 * kicked. Leave it pointing to the original bridge.
2291 */
2292 continue;
2293 }
2294
2295 bridge_channel_moving(bridge_channel, bridge_channel->bridge, dst_bridge);
2296
2297 /* Point to new bridge.*/
2298 bridge_channel_change_bridge(bridge_channel, dst_bridge);
2299
2300 if (bridge_channel_internal_push(bridge_channel)) {
2301 ast_bridge_features_remove(bridge_channel->features,
2303 ast_bridge_channel_leave_bridge(bridge_channel,
2305 }
2306 }
2308
2309 if (kick_me) {
2310 /*
2311 * Now we can kick any channels in the dst_bridge without
2312 * potentially dissolving the bridge.
2313 */
2314 for (idx = 0; idx < num_kick; ++idx) {
2315 bridge_channel = kick_me[idx];
2316 ast_bridge_channel_lock(bridge_channel);
2317 if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
2320 bridge_channel_internal_pull(bridge_channel);
2321 }
2322 ast_bridge_channel_unlock(bridge_channel);
2323 }
2324 }
2325
2326 bridge_reconfigured(dst_bridge, !optimized);
2327 bridge_reconfigured(src_bridge, !optimized);
2328
2329 ast_debug(1, "Merged bridge %s into bridge %s\n",
2330 src_bridge->uniqueid, dst_bridge->uniqueid);
2331}
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:3710
void bridge_reconfigured(struct ast_bridge *bridge, unsigned int colp_update)
Definition bridge.c:1602
static void bridge_channel_change_bridge(struct ast_bridge_channel *bridge_channel, struct ast_bridge *new_bridge)
Definition bridge.c:2206
static void bridge_channel_moving(struct ast_bridge_channel *bridge_channel, struct ast_bridge *src, struct ast_bridge *dst)
Definition bridge.c:2221
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
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).
@ BRIDGE_CHANNEL_STATE_WAIT
int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel)
void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel)
@ AST_BRIDGE_HOOK_REMOVE_ON_PULL
@ AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
void ast_bridge_publish_merge(struct ast_bridge *to, struct ast_bridge *from)
Publish a bridge merge.
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_bridge_features * features
enum bridge_channel_state state
struct ast_bridge_channel::@201 entry
struct ast_flags feature_flags
#define ast_test_flag(p, flag)
Definition utils.h:64

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_channel::entry, 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().

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

2515{
2516 struct ast_bridge *orig_bridge;
2517 int was_in_bridge;
2518 int res = 0;
2519
2520 if (bridge_channel->swap) {
2521 ast_debug(1, "Moving %p(%s) into bridge %s swapping with %s\n",
2522 bridge_channel, ast_channel_name(bridge_channel->chan), dst_bridge->uniqueid,
2523 ast_channel_name(bridge_channel->swap));
2524 } else {
2525 ast_debug(1, "Moving %p(%s) into bridge %s\n",
2526 bridge_channel, ast_channel_name(bridge_channel->chan), dst_bridge->uniqueid);
2527 }
2528
2529 orig_bridge = bridge_channel->bridge;
2530 was_in_bridge = bridge_channel->in_bridge;
2531
2532 bridge_channel_internal_pull(bridge_channel);
2533 if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
2534 /*
2535 * The channel died as a result of being pulled. Leave it
2536 * pointing to the original bridge.
2537 *
2538 * Clear out the swap channel pointer. A ref is not held
2539 * by bridge_channel->swap at this point.
2540 */
2541 bridge_channel->swap = NULL;
2542 bridge_reconfigured(orig_bridge, 0);
2543 return -1;
2544 }
2545
2546 /* Point to new bridge.*/
2547 ao2_ref(orig_bridge, +1);/* Keep a ref in case the push fails. */
2548 bridge_channel_change_bridge(bridge_channel, dst_bridge);
2549
2550 bridge_channel_moving(bridge_channel, orig_bridge, dst_bridge);
2551
2552 if (bridge_channel_internal_push_full(bridge_channel, optimized)) {
2553 /* Try to put the channel back into the original bridge. */
2554 ast_bridge_features_remove(bridge_channel->features,
2556 if (attempt_recovery && was_in_bridge) {
2557 /* Point back to original bridge. */
2558 bridge_channel_change_bridge(bridge_channel, orig_bridge);
2559
2560 if (bridge_channel_internal_push(bridge_channel)) {
2561 ast_bridge_features_remove(bridge_channel->features,
2563 ast_bridge_channel_leave_bridge(bridge_channel,
2565 }
2566 } else {
2567 ast_bridge_channel_leave_bridge(bridge_channel,
2569 bridge_channel_settle_owed_events(orig_bridge, bridge_channel);
2570 }
2571 res = -1;
2572 } else if (!optimized) {
2573 bridge_channel_settle_owed_events(orig_bridge, bridge_channel);
2574 }
2575
2576 bridge_reconfigured(dst_bridge, !optimized);
2577 bridge_reconfigured(orig_bridge, !optimized);
2578 ao2_ref(orig_bridge, -1);
2579 return res;
2580}
void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel)
int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel, int optimized)
struct ast_channel * swap
unsigned int in_bridge

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

◆ bridge_find_channel()

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

◆ bridge_merge_inhibit_nolock()

void bridge_merge_inhibit_nolock ( struct ast_bridge bridge,
int  request 
)

Definition at line 3200 of file bridge.c.

3201{
3202 int new_request;
3203
3204 new_request = bridge->inhibit_merge + request;
3205 ast_assert(0 <= new_request);
3206 bridge->inhibit_merge = new_request;
3207}
static int request(void *obj)
unsigned int inhibit_merge
Count of the active temporary requests to inhibit bridge merges. Zero if merges are allowed.
Definition bridge.h:390

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

Referenced by ast_bridge_channel_merge_inhibit(), and ast_bridge_merge_inhibit().

◆ bridge_reconfigured()

void bridge_reconfigured ( struct ast_bridge bridge,
unsigned int  colp_update 
)

Definition at line 1602 of file bridge.c.

1603{
1604 if (!bridge->reconfigured) {
1605 return;
1606 }
1607 bridge->reconfigured = 0;
1609 && smart_bridge_operation(bridge)) {
1610 /* Smart bridge failed. */
1611 bridge_dissolve(bridge, 0);
1612 return;
1613 }
1614 bridge_complete_join(bridge);
1615
1616 if (bridge->dissolved) {
1617 return;
1618 }
1620 set_bridge_peer_vars(bridge);
1622
1623 if (colp_update) {
1625 }
1626}
void bridge_dissolve(struct ast_bridge *bridge, int cause)
Definition bridge.c:337
static void check_bridge_play_sounds(struct ast_bridge *bridge)
Definition bridge.c:1292
static int smart_bridge_operation(struct ast_bridge *bridge)
Definition bridge.c:1061
static void bridge_reconfigured_connected_line_update(struct ast_bridge *bridge)
Definition bridge.c:415
static void bridge_complete_join(struct ast_bridge *bridge)
Definition bridge.c:504
static void set_bridge_peer_vars(struct ast_bridge *bridge)
Definition bridge.c:1585
@ AST_BRIDGE_FLAG_SMART
void ast_bridge_publish_state(struct ast_bridge *bridge)
Publish the state of a bridge.
unsigned int reconfigured
Definition bridge.h:394

References AST_BRIDGE_FLAG_SMART, ast_bridge_publish_state(), ast_test_flag, ast_bridge_channel::bridge, 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().

◆ 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;
}
struct ast_bridge_methods ast_bridge_basic_v_table
Bridge basic class virtual method table.
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
struct ast_bridge * bridge_register(struct ast_bridge *bridge)
Register the new bridge with the system.
Definition bridge.c:731
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.
Returns
bridge on success.
Return values
NULLon error.

Definition at line 731 of file bridge.c.

732{
733 if (bridge) {
735 /*
736 * Although bridge_base_init() should have already checked for
737 * an existing bridge with the same uniqueid, bridge_base_init()
738 * and bridge_register() are two separate public APIs so we need
739 * to check again here.
740 */
741 struct ast_bridge *existing = ast_bridge_find_by_id(bridge->uniqueid);
742 if (existing) {
743 ast_log(LOG_WARNING, "Bridge " BRIDGE_PRINTF_SPEC ": already registered\n",
744 BRIDGE_PRINTF_VARS(bridge));
745 ao2_ref(existing, -1);
746 ast_bridge_destroy(bridge, 0);
747 return NULL;
748 }
749 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": registering\n",
750 BRIDGE_PRINTF_VARS(bridge));
751 bridge->construction_completed = 1;
752 ast_bridge_lock(bridge);
754 ast_bridge_unlock(bridge);
755 if (!ao2_link(bridges, bridge)) {
756 ast_log(LOG_WARNING, "Bridge " BRIDGE_PRINTF_SPEC ": failed to link\n",
757 BRIDGE_PRINTF_VARS(bridge));
758 ast_bridge_destroy(bridge, 0);
759 bridge = NULL;
760 }
761 }
762 return bridge;
763}
#define ao2_link(container, obj)
Add an object to a container.
Definition astobj2.h:1532
struct ast_bridge * ast_bridge_find_by_id(const char *bridge_id)
Find bridge by id.
Definition bridge.c:5221
static struct ao2_container * bridges
Definition bridge.c:132
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition bridge.h:491
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition bridge.h:480
unsigned int construction_completed
Definition bridge.h:398

References ao2_link, ao2_ref, ast_bridge_destroy(), ast_bridge_find_by_id(), ast_bridge_lock, ast_bridge_publish_state(), ast_bridge_unlock, ast_debug, ast_log, bridge_init_lock, BRIDGE_PRINTF_SPEC, BRIDGE_PRINTF_VARS, bridges, ast_bridge::construction_completed, lock, LOG_WARNING, NULL, SCOPED_MUTEX, 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().