Asterisk - The Open Source Telephony Project GIT-master-6144b6b
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
stasis_bridges.h File Reference
#include "asterisk/stringfields.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/pbx.h"
Include dependency graph for stasis_bridges.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_attended_transfer_message
 Message representing attended transfer. More...
 
struct  ast_blind_transfer_message
 Message published during a blind transfer. More...
 
struct  ast_bridge_blob
 Blob of data associated with a bridge. More...
 
struct  ast_bridge_channel_snapshot_pair
 Pair showing a bridge snapshot and a specific channel snapshot belonging to the bridge. More...
 
struct  ast_bridge_merge_message
 Message representing the merge of two bridges. More...
 
struct  ast_bridge_snapshot_update
 

Enumerations

enum  ast_attended_transfer_dest_type {
  AST_ATTENDED_TRANSFER_DEST_FAIL , AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE , AST_ATTENDED_TRANSFER_DEST_APP , AST_ATTENDED_TRANSFER_DEST_LOCAL_APP ,
  AST_ATTENDED_TRANSFER_DEST_LINK , AST_ATTENDED_TRANSFER_DEST_THREEWAY
}
 

Functions

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.
 
int ast_attended_transfer_message_add_link (struct ast_attended_transfer_message *transfer_msg, struct ast_channel *locals[2])
 Add details for an attended transfer that has a link between bridges.
 
int ast_attended_transfer_message_add_merge (struct ast_attended_transfer_message *transfer_msg, struct ast_bridge *final_bridge)
 Add details for a bridge merge to an attended transfer message.
 
int ast_attended_transfer_message_add_threeway (struct ast_attended_transfer_message *transfer_msg, struct ast_channel *survivor_channel, struct ast_bridge *survivor_bridge)
 Add details for an attended transfer that was resolved as a three-way call.
 
struct ast_attended_transfer_messageast_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.
 
struct stasis_message_typeast_attended_transfer_type (void)
 Message type for ast_attended_transfer_message.
 
struct ast_blind_transfer_messageast_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.
 
struct stasis_message_typeast_blind_transfer_type (void)
 Message type for ast_blind_transfer_message.
 
struct stasis_messageast_bridge_blob_create (struct stasis_message_type *type, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_json *blob)
 Creates a ast_bridge_blob message.
 
struct stasis_messageast_bridge_blob_create_from_snapshots (struct stasis_message_type *type, struct ast_bridge_snapshot *bridge_snapshot, struct ast_channel_snapshot *chan_snapshot, struct ast_json *blob)
 Creates a ast_bridge_blob message from snapshots.
 
struct ast_bridge_snapshotast_bridge_get_snapshot (struct ast_bridge *bridge)
 Returns the current snapshot for the bridge.
 
struct ast_bridge_snapshotast_bridge_get_snapshot_by_uniqueid (const char *bridge_id)
 Returns the current snapshot for the bridge.
 
struct stasis_message_typeast_bridge_merge_message_type (void)
 Message type for ast_bridge_merge_message.
 
void ast_bridge_publish_attended_transfer (struct ast_attended_transfer_message *transfer_msg)
 Publish an attended transfer.
 
void ast_bridge_publish_blind_transfer (struct ast_blind_transfer_message *transfer_message)
 Publish a blind transfer event.
 
void ast_bridge_publish_enter (struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
 Publish a bridge channel enter event.
 
void ast_bridge_publish_leave (struct ast_bridge *bridge, struct ast_channel *chan)
 Publish a bridge channel leave event.
 
void ast_bridge_publish_merge (struct ast_bridge *to, struct ast_bridge *from)
 Publish a bridge merge.
 
void ast_bridge_publish_state (struct ast_bridge *bridge)
 Publish the state of a bridge.
 
struct ast_bridge_snapshotast_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_jsonast_bridge_snapshot_to_json (const struct ast_bridge_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
 Build a JSON object from a ast_bridge_snapshot.
 
struct stasis_message_typeast_bridge_snapshot_type (void)
 Message type for ast_bridge_snapshot.
 
struct stasis_topicast_bridge_topic (struct ast_bridge *bridge)
 A topic which publishes the events for a particular bridge.
 
struct stasis_topicast_bridge_topic_all (void)
 A topic which publishes the events for all bridges.
 
int ast_bridge_topic_exists (const char *uniqueid)
 Check if a stasis topic exists for a bridge uniqueid.
 
struct stasis_message_typeast_channel_entered_bridge_type (void)
 Message type for ast_channel enter bridge blob messages.
 
struct stasis_message_typeast_channel_left_bridge_type (void)
 Message type for ast_channel leave bridge blob messages.
 
int ast_stasis_bridging_init (void)
 
void bridge_topics_destroy (struct ast_bridge *bridge)
 
int bridge_topics_init (struct ast_bridge *bridge)
 

Enumeration Type Documentation

◆ ast_attended_transfer_dest_type

Enumerator
AST_ATTENDED_TRANSFER_DEST_FAIL 

The transfer failed, so there is no appropriate final state

AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE 

The transfer results in a single bridge remaining due to a merge or swap

AST_ATTENDED_TRANSFER_DEST_APP 

The transfer results in a channel or bridge running an application

AST_ATTENDED_TRANSFER_DEST_LOCAL_APP 

The transfer results in a channel or bridge running an application via a local channel

AST_ATTENDED_TRANSFER_DEST_LINK 

The transfer results in both bridges remaining with a local channel linking them

AST_ATTENDED_TRANSFER_DEST_THREEWAY 

The transfer results in a threeway call between transferer, transferee, and transfer target

Definition at line 303 of file stasis_bridges.h.

303 {
304 /*! The transfer failed, so there is no appropriate final state */
306 /*! The transfer results in a single bridge remaining due to a merge or swap */
308 /*! The transfer results in a channel or bridge running an application */
310 /*! The transfer results in a channel or bridge running an application via a local channel */
312 /*! The transfer results in both bridges remaining with a local channel linking them */
314 /*! The transfer results in a threeway call between transferer, transferee, and transfer target */
316};
@ AST_ATTENDED_TRANSFER_DEST_FAIL
@ AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE
@ AST_ATTENDED_TRANSFER_DEST_LOCAL_APP
@ AST_ATTENDED_TRANSFER_DEST_LINK
@ AST_ATTENDED_TRANSFER_DEST_APP
@ AST_ATTENDED_TRANSFER_DEST_THREEWAY

Function Documentation

◆ ast_attended_transfer_message_add_app()

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.

If the transfer is sending one or more parties into an application, then this should be called to add appropriate details to the transfer message being published.

Parameters
transfer_msgThe message to add details to
appThe name of the application that the parties are being transferred to
replace_channelThe local channel that is in the bridge and running the application
Return values
0Success
-1Failure

Definition at line 1361 of file stasis_bridges.c.

1363{
1365
1366 if (replace_channel) {
1368 if (!transfer_msg->replace_channel) {
1369 return -1;
1370 }
1371 }
1372
1373 ast_copy_string(transfer_msg->dest.app, app, sizeof(transfer_msg->dest.app));
1374
1375 return 0;
1376}
static const char app[]
const char * ast_channel_uniqueid(const struct ast_channel *chan)
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,...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
enum ast_attended_transfer_dest_type dest_type
struct ast_channel_snapshot * replace_channel
union ast_attended_transfer_message::@303 dest

References app, ast_attended_transfer_message::app, AST_ATTENDED_TRANSFER_DEST_APP, AST_ATTENDED_TRANSFER_DEST_LOCAL_APP, ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_copy_string(), ast_attended_transfer_message::dest, ast_attended_transfer_message::dest_type, and ast_attended_transfer_message::replace_channel.

Referenced by ast_bridge_transfer_attended(), and attended_transfer_bridge().

◆ ast_attended_transfer_message_add_link()

int ast_attended_transfer_message_add_link ( struct ast_attended_transfer_message transfer_msg,
struct ast_channel locals[2] 
)

Add details for an attended transfer that has a link between bridges.

An attended transfer may be accomplished by linking two bridges together with local channels. If this is how the transfer is to be completed, call this function in order to fill in details about the transfer.

Parameters
transfer_msgThe message to add details to.
localsAn array of local channel halves that each are in one of the involved bridges.
Return values
0Success
-1Failure

Definition at line 1378 of file stasis_bridges.c.

1380{
1381 int i;
1382
1384 for (i = 0; i < 2; ++i) {
1386 if (!transfer_msg->dest.links[i]) {
1387 return -1;
1388 }
1389 }
1390
1391 return 0;
1392}
static struct ao2_container * locals
Definition core_local.c:150
struct ast_channel_snapshot * links[2]

References AST_ATTENDED_TRANSFER_DEST_LINK, ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_attended_transfer_message::dest, ast_attended_transfer_message::dest_type, ast_attended_transfer_message::links, and locals.

Referenced by attended_transfer_bridge().

◆ ast_attended_transfer_message_add_merge()

int ast_attended_transfer_message_add_merge ( struct ast_attended_transfer_message transfer_msg,
struct ast_bridge final_bridge 
)

Add details for a bridge merge to an attended transfer message.

If the transfer is accomplished by a bridge merge (or swap optimization), then this should be called on the created attended transfer message to have the appropriate details added on.

Parameters
transfer_msgThe transfer message to add details to
final_bridgeThe bridge where the surviving parties reside
Return values
0Success
-1Failure

Definition at line 1331 of file stasis_bridges.c.

1333{
1335 ast_copy_string(transfer_msg->dest.bridge, final_bridge->uniqueid,
1336 sizeof(transfer_msg->dest.bridge));
1337
1338 return 0;
1339}
char bridge[AST_UUID_STR_LEN]
const ast_string_field uniqueid
Definition bridge.h:407

References AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE, ast_copy_string(), ast_attended_transfer_message::bridge, ast_attended_transfer_message::dest, ast_attended_transfer_message::dest_type, and ast_bridge::uniqueid.

Referenced by publish_transfer_success(), and two_bridge_attended_transfer().

◆ ast_attended_transfer_message_add_threeway()

int ast_attended_transfer_message_add_threeway ( struct ast_attended_transfer_message transfer_msg,
struct ast_channel survivor_channel,
struct ast_bridge survivor_bridge 
)

Add details for an attended transfer that was resolved as a three-way call.

If the transfer results in a three-way call between the transferer, the transferee, and the transfer target, then this should be called in order to add appropriate details to the transfer message to be published.

Parameters
transfer_msgThe message to add details to
survivor_channelThe transferer channel that exists in the three-way call
survivor_bridgeThe bridge where the three-way call takes place.
Return values
0Success
-1Failure

Definition at line 1341 of file stasis_bridges.c.

1343{
1345
1346 if (!strcmp(ast_channel_uniqueid(survivor_channel), transfer_msg->to_transferee.channel_snapshot->base->uniqueid)) {
1347 transfer_msg->dest.threeway.channel_snapshot = transfer_msg->to_transferee.channel_snapshot;
1348 } else {
1350 }
1351
1352 if (!strcmp(survivor_bridge->uniqueid, transfer_msg->to_transferee.bridge_snapshot->uniqueid)) {
1353 transfer_msg->dest.threeway.bridge_snapshot = transfer_msg->to_transferee.bridge_snapshot;
1354 } else {
1355 transfer_msg->dest.threeway.bridge_snapshot = transfer_msg->to_transfer_target.bridge_snapshot;
1356 }
1357
1358 return 0;
1359}
struct ast_bridge_channel_snapshot_pair to_transfer_target
struct ast_bridge_channel_snapshot_pair threeway
struct ast_bridge_channel_snapshot_pair to_transferee
struct ast_bridge_snapshot * bridge_snapshot
struct ast_channel_snapshot * channel_snapshot
const ast_string_field uniqueid
Definition bridge.h:332
const ast_string_field uniqueid
struct ast_channel_snapshot_base * base

References AST_ATTENDED_TRANSFER_DEST_THREEWAY, ast_channel_uniqueid(), ast_channel_snapshot::base, ast_bridge_channel_snapshot_pair::bridge_snapshot, ast_bridge_channel_snapshot_pair::channel_snapshot, ast_attended_transfer_message::dest, ast_attended_transfer_message::dest_type, ast_attended_transfer_message::threeway, ast_attended_transfer_message::to_transfer_target, ast_attended_transfer_message::to_transferee, ast_bridge_snapshot::uniqueid, ast_bridge::uniqueid, and ast_channel_snapshot_base::uniqueid.

Referenced by publish_transfer_threeway().

◆ ast_attended_transfer_message_create()

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.

The parameters to this function are the basic necessities in order to create the initial attended transfer message.

The transferee and transfer_target parameters are optional. If not provided, then this function will attempt to determine who the transferee and transfer target are based on the input transferer channels and bridges. You typically will not need to provide an explicit transferee and transfer target channel unless your attended transfer is implemented in a strange way.

Parameters
is_externalNon-zero if the transfer was initiated by a native channel driver protocol.
to_transfereeThe transferer channel that is bridged to the transferee channel.
transferee_bridgeThe bridge between the transferer and transferee. May be NULL.
to_transfer_targetThe transferer channel that is bridged to the transfer target.
target_bridgeThe bridge between the transferer and transfer target. May be NULL.
transfereeThe channel that is being transferred. Optional.
transfer_targetThe channel that is being transferred to. Optional.
Return values
NULLFailure to allocate or create snapshots
non-NULLThe created attended transfer message

Definition at line 1274 of file stasis_bridges.c.

1278{
1279 struct ast_attended_transfer_message *transfer_msg;
1280
1281 transfer_msg = ao2_alloc(sizeof(*transfer_msg), attended_transfer_dtor);
1282 if (!transfer_msg) {
1283 return NULL;
1284 }
1285
1286 if (bridge_channel_snapshot_pair_init(to_transferee, transferee_bridge, &transfer_msg->to_transferee) ||
1288 ao2_cleanup(transfer_msg);
1289 return NULL;
1290 }
1291
1292 if (transferee) {
1294 if (!transfer_msg->transferee) {
1295 ao2_cleanup(transfer_msg);
1296 return NULL;
1297 }
1298 } else if (transferee_bridge) {
1299 transferee = ast_bridge_peer(transferee_bridge, to_transferee);
1300 if (transferee) {
1303 if (!transfer_msg->transferee) {
1304 ao2_cleanup(transfer_msg);
1305 return NULL;
1306 }
1307 }
1308 }
1309
1310 if (transfer_target) {
1311 transfer_msg->target = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transfer_target));
1312 if (!transfer_msg->target) {
1313 ao2_cleanup(transfer_msg);
1314 return NULL;
1315 }
1316 } else if (target_bridge) {
1317 transfer_target = ast_bridge_peer(target_bridge, to_transfer_target);
1318 if (transfer_target) {
1319 transfer_msg->target = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transfer_target));
1320 ao2_cleanup(transfer_target);
1321 if (!transfer_msg->target) {
1322 ao2_cleanup(transfer_msg);
1323 return NULL;
1324 }
1325 }
1326 }
1327
1328 return transfer_msg;
1329}
#define ao2_cleanup(obj)
Definition astobj2.h:1934
#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:4284
#define NULL
Definition resample.c:96
static void attended_transfer_dtor(void *obj)
static int bridge_channel_snapshot_pair_init(struct ast_channel *channel, struct ast_bridge *bridge, struct ast_bridge_channel_snapshot_pair *snapshot_pair)
Message representing attended transfer.
struct ast_channel_snapshot * transferee
struct ast_channel_snapshot * target

References ao2_alloc, ao2_cleanup, ast_bridge_peer(), ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), attended_transfer_dtor(), bridge_channel_snapshot_pair_init(), NULL, ast_attended_transfer_message::target, ast_attended_transfer_message::to_transfer_target, ast_attended_transfer_message::to_transferee, and ast_attended_transfer_message::transferee.

Referenced by ast_bridge_transfer_attended(), publish_transfer_fail(), publish_transfer_success(), and publish_transfer_threeway().

◆ ast_attended_transfer_type()

struct stasis_message_type * ast_attended_transfer_type ( void  )

◆ ast_blind_transfer_message_create()

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.

Parameters
is_externalWhether the blind transfer was initiated externally (e.g. via AMI or native protocol)
transfererThe transferer's channel that is bridged to the transferee
extenThe destination extension for the blind transfer
contextThe destination context for the blind transfer
Return values
NULLFailure to allocate or create snapshots
non-NULLThe created blind transfer message

Definition at line 977 of file stasis_bridges.c.

979{
980 struct ast_blind_transfer_message *msg;
981
982 msg = ao2_alloc(sizeof(*msg), blind_transfer_dtor);
983 if (!msg) {
984 return NULL;
985 }
986
988 if (!msg->transferer) {
989 ao2_cleanup(msg);
990 return NULL;
991 }
992
994 ast_copy_string(msg->context, context, sizeof(msg->context));
995 ast_copy_string(msg->exten, exten, sizeof(msg->exten));
996
997 return msg;
998}
static void blind_transfer_dtor(void *obj)
Message published during a blind transfer.
char exten[AST_MAX_EXTENSION]
struct ast_channel_snapshot * transferer
char context[AST_MAX_CONTEXT]

References ao2_alloc, ao2_cleanup, ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_copy_string(), blind_transfer_dtor(), ast_blind_transfer_message::context, ast_blind_transfer_message::exten, ast_blind_transfer_message::is_external, NULL, and ast_blind_transfer_message::transferer.

Referenced by ast_bridge_transfer_blind(), and AST_TEST_DEFINE().

◆ ast_blind_transfer_type()

struct stasis_message_type * ast_blind_transfer_type ( void  )

◆ ast_bridge_blob_create()

struct stasis_message * ast_bridge_blob_create ( struct stasis_message_type type,
struct ast_bridge bridge,
struct ast_channel chan,
struct ast_json blob 
)

Creates a ast_bridge_blob message.

Since
12

The blob JSON object requires a "type" field describing the blob. It should also be treated as immutable and not modified after it is put into the message.

Precondition
bridge is locked.
No channels are locked.
Parameters
type
bridgeChannel blob is associated with, or NULL for global/all bridges.
chanThe channel that started the bridge
blobJSON object representing the data.
Returns
ast_bridge_blob message.
Return values
NULLon error

Definition at line 543 of file stasis_bridges.c.

548{
549 struct ast_bridge_blob *obj;
550 struct stasis_message *msg;
551
552 if (!message_type) {
553 return NULL;
554 }
555
556 obj = ao2_alloc(sizeof(*obj), bridge_blob_dtor);
557 if (!obj) {
558 return NULL;
559 }
560
561 if (bridge) {
562 obj->bridge = ast_bridge_snapshot_create(bridge);
563 if (obj->bridge == NULL) {
564 ao2_ref(obj, -1);
565
566 return NULL;
567 }
568 }
569
570 if (chan) {
572 if (obj->channel == NULL) {
573 ao2_ref(obj, -1);
574
575 return NULL;
576 }
577 }
578
579 if (blob) {
580 obj->blob = ast_json_ref(blob);
581 }
582
583 msg = stasis_message_create(message_type, obj);
584 ao2_ref(obj, -1);
585
586 return msg;
587}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition json.c:67
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
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.
static void bridge_blob_dtor(void *obj)
Blob of data associated with a bridge.
struct ast_bridge_snapshot * bridge
struct ast_channel_snapshot * channel
struct ast_json * blob

References ao2_alloc, ao2_ref, ast_bridge_snapshot_create(), ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_json_ref(), ast_bridge_blob::blob, ast_bridge_blob::bridge, bridge_blob_dtor(), ast_bridge_blob::channel, NULL, and stasis_message_create().

Referenced by ast_bridge_publish_enter(), ast_bridge_publish_leave(), and send_conf_stasis().

◆ ast_bridge_blob_create_from_snapshots()

struct stasis_message * ast_bridge_blob_create_from_snapshots ( struct stasis_message_type type,
struct ast_bridge_snapshot bridge_snapshot,
struct ast_channel_snapshot chan_snapshot,
struct ast_json blob 
)

Creates a ast_bridge_blob message from snapshots.

Since
13.28
16.5

The blob JSON object requires a "type" field describing the blob. It should also be treated as immutable and not modified after it is put into the message.

Precondition
bridge is locked.
No channels are locked.
Parameters
type
bridge_snapshotBridge snapshot
chan_snapshotChannel snapshot
blobJSON object representing the data.
Returns
ast_bridge_blob message.
Return values
NULLon error

Definition at line 589 of file stasis_bridges.c.

594{
595 struct ast_bridge_blob *obj;
596 struct stasis_message *msg;
597
598 if (!message_type) {
599 return NULL;
600 }
601
602 obj = ao2_alloc(sizeof(*obj), bridge_blob_dtor);
603 if (!obj) {
604 return NULL;
605 }
606
607 if (bridge_snapshot) {
608 obj->bridge = ao2_bump(bridge_snapshot);
609 }
610
611 if (chan_snapshot) {
612 obj->channel = ao2_bump(chan_snapshot);
613 }
614
615 if (blob) {
616 obj->blob = ast_json_ref(blob);
617 }
618
619 msg = stasis_message_create(message_type, obj);
620 ao2_ref(obj, -1);
621
622 return msg;
623}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480

References ao2_alloc, ao2_bump, ao2_ref, ast_json_ref(), ast_bridge_blob::blob, ast_bridge_blob::bridge, bridge_blob_dtor(), ast_bridge_blob::channel, NULL, and stasis_message_create().

Referenced by send_conf_stasis_snapshots().

◆ ast_bridge_get_snapshot()

struct ast_bridge_snapshot * ast_bridge_get_snapshot ( struct ast_bridge bridge)

Returns the current snapshot for the bridge.

Since
17.0

The returned pointer is AO2 managed, so ao2_cleanup() when you're done.

Parameters
bridgeThe bridge from which to get the snapshot.
Returns
Most recent snapshot. ao2_cleanup() when done.
Return values
NULLif there isn't a snapshot.

Definition at line 1426 of file stasis_bridges.c.

1427{
1428 struct ast_bridge_snapshot *snapshot;
1429
1430 if (!bridge) {
1431 return NULL;
1432 }
1433 ast_bridge_lock(bridge);
1434 snapshot = ao2_bump(bridge->current_snapshot);
1435 ast_bridge_unlock(bridge);
1436
1437 return snapshot;
1438}
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition bridge.h:491
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition bridge.h:480
Structure that contains a snapshot of information about a bridge.
Definition bridge.h:318
struct ast_bridge_snapshot * current_snapshot
Definition bridge.h:412

References ao2_bump, ast_bridge_lock, ast_bridge_unlock, ast_bridge::current_snapshot, and NULL.

Referenced by ast_ari_bridges_list(), ast_refer_notify_transfer_request(), bridges_scrape_cb(), handle_bridge_show_all(), send_bridge_list_item_cb(), and test_cel_generate_peer_str_snapshot().

◆ ast_bridge_get_snapshot_by_uniqueid()

struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid ( const char *  bridge_id)

Returns the current snapshot for the bridge.

Since
17.0

The returned pointer is AO2 managed, so ao2_cleanup() when you're done.

Parameters
bridge_idUniqueid of the bridge from which to get the snapshot.
Returns
Most recent snapshot. ao2_cleanup() when done.
Return values
NULLif bridge or snapshot doesn't exist.

Definition at line 1407 of file stasis_bridges.c.

1408{
1409 struct ast_bridge *bridge;
1410 struct ast_bridge_snapshot *snapshot;
1411
1413
1415 if (!bridge) {
1416 return NULL;
1417 }
1418 ast_bridge_lock(bridge);
1419 snapshot = ao2_bump(bridge->current_snapshot);
1420 ast_bridge_unlock(bridge);
1421 ao2_ref(bridge, -1);
1422
1423 return snapshot;
1424}
struct ast_bridge * ast_bridge_find_by_id(const char *bridge_id)
Find bridge by id.
Definition bridge.c:5221
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
Structure that contains information about a bridge.
Definition bridge.h:355
#define ast_assert(a)
Definition utils.h:779

References ao2_bump, ao2_ref, ast_assert, ast_bridge_find_by_id(), ast_bridge_lock, ast_bridge_unlock, ast_strlen_zero(), ast_bridge::current_snapshot, NULL, and ast_bridge_snapshot::uniqueid.

Referenced by action_coreshowchannelmap(), ast_ari_bridges_get(), coreshowchannelmap_add_connected_channels(), find_bridge(), handle_bridge_show_specific(), manager_bridge_info(), and stasis_app_user_event().

◆ ast_bridge_merge_message_type()

struct stasis_message_type * ast_bridge_merge_message_type ( void  )

◆ ast_bridge_publish_attended_transfer()

void ast_bridge_publish_attended_transfer ( struct ast_attended_transfer_message transfer_msg)

Publish an attended transfer.

Parameters
transfer_msgThe transfer message to publish

Definition at line 1394 of file stasis_bridges.c.

1395{
1396 struct stasis_message *msg;
1397
1399 if (!msg) {
1400 return;
1401 }
1402
1404 ao2_ref(msg, -1);
1405}
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition stasis.c:1589
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
struct stasis_message_type * ast_attended_transfer_type(void)
Message type for ast_attended_transfer_message.

References ao2_ref, ast_attended_transfer_type(), ast_bridge_topic_all(), stasis_message_create(), and stasis_publish().

Referenced by ast_bridge_transfer_attended(), publish_transfer_fail(), publish_transfer_success(), and publish_transfer_threeway().

◆ ast_bridge_publish_blind_transfer()

void ast_bridge_publish_blind_transfer ( struct ast_blind_transfer_message transfer_message)

Publish a blind transfer event.

Precondition
Bridges involved are locked. Channels involved are not locked.
Parameters
transfer_message

Definition at line 1001 of file stasis_bridges.c.

1002{
1003 struct stasis_message *stasis;
1004
1006 if (!stasis) {
1007 return;
1008 }
1009
1011
1013}
static const char * stasis
Dialplan application name.
Definition app_stasis.c:85
struct stasis_message_type * ast_blind_transfer_type(void)
Message type for ast_blind_transfer_message.

References ao2_cleanup, ast_blind_transfer_type(), ast_bridge_topic_all(), stasis, stasis_message_create(), and stasis_publish().

Referenced by ast_bridge_transfer_blind(), and AST_TEST_DEFINE().

◆ ast_bridge_publish_enter()

void ast_bridge_publish_enter ( struct ast_bridge bridge,
struct ast_channel chan,
struct ast_channel swap 
)

Publish a bridge channel enter event.

Since
12
Precondition
bridge is locked.
No channels are locked.
Parameters
bridgeThe bridge a channel entered
chanThe channel that entered the bridge
swapThe channel being swapped out of the bridge

Definition at line 625 of file stasis_bridges.c.

627{
628 struct stasis_message *msg;
629 struct ast_json *blob = NULL;
630
632 return;
633 }
634
635 if (swap) {
636 blob = ast_json_pack("{s: s}", "swap", ast_channel_uniqueid(swap));
637 if (!blob) {
638 return;
639 }
640 }
641
642 msg = ast_bridge_blob_create(ast_channel_entered_bridge_type(), bridge, chan, blob);
643 ast_json_unref(blob);
644 if (!msg) {
645 return;
646 }
647
648 /* enter blob first, then state */
649 stasis_publish(ast_bridge_topic(bridge), msg);
651 ao2_ref(msg, -1);
652}
@ AST_BRIDGE_FLAG_INVISIBLE
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * ast_bridge_blob_create(struct stasis_message_type *message_type, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_json *blob)
Creates a ast_bridge_blob message.
static void bridge_publish_state_from_blob(struct ast_bridge *bridge, struct ast_bridge_blob *obj)
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
struct stasis_message_type * ast_channel_entered_bridge_type(void)
Message type for ast_channel enter bridge blob messages.
struct ast_flags feature_flags
Definition bridge.h:375
Abstract JSON element (object, array, string, int, ...).
#define ast_test_flag(p, flag)
Definition utils.h:64

References ao2_ref, ast_bridge_blob_create(), AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic(), ast_channel_entered_bridge_type(), ast_channel_uniqueid(), ast_json_pack(), ast_json_unref(), ast_test_flag, bridge_publish_state_from_blob(), ast_bridge::feature_flags, NULL, stasis_message_data(), and stasis_publish().

Referenced by bridge_channel_internal_push_full().

◆ ast_bridge_publish_leave()

void ast_bridge_publish_leave ( struct ast_bridge bridge,
struct ast_channel chan 
)

Publish a bridge channel leave event.

Since
12
Precondition
bridge is locked.
No channels are locked.
Parameters
bridgeThe bridge a channel left
chanThe channel that left the bridge

Definition at line 654 of file stasis_bridges.c.

655{
656 struct stasis_message *msg;
657
659 return;
660 }
662 if (!msg) {
663 return;
664 }
665
666 /* state first, then leave blob (opposite of enter, preserves nesting of events) */
668 stasis_publish(ast_bridge_topic(bridge), msg);
669 ao2_ref(msg, -1);
670}
struct stasis_message_type * ast_channel_left_bridge_type(void)
Message type for ast_channel leave bridge blob messages.

References ao2_ref, ast_bridge_blob_create(), AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic(), ast_channel_left_bridge_type(), ast_test_flag, bridge_publish_state_from_blob(), ast_bridge::feature_flags, NULL, stasis_message_data(), and stasis_publish().

Referenced by bridge_channel_internal_pull().

◆ ast_bridge_publish_merge()

void ast_bridge_publish_merge ( struct ast_bridge to,
struct ast_bridge from 
)

Publish a bridge merge.

Since
12
Precondition
Bridges involved are locked
Parameters
toThe bridge to which channels are being added
fromThe bridge from which channels are being removed

Definition at line 503 of file stasis_bridges.c.

504{
505 struct ast_bridge_merge_message *merge_msg;
506 struct stasis_message *msg;
507
509 return;
510 }
511
512 ast_assert(to != NULL);
513 ast_assert(from != NULL);
516
517 merge_msg = bridge_merge_message_create(to, from);
518 if (!merge_msg) {
519 return;
520 }
521
523 ao2_ref(merge_msg, -1);
524 if (!msg) {
525 return;
526 }
527
529 ao2_ref(msg, -1);
530}
static struct ast_bridge_merge_message * bridge_merge_message_create(struct ast_bridge *to, struct ast_bridge *from)
Bridge merge message creation helper.
struct stasis_message_type * ast_bridge_merge_message_type(void)
Message type for ast_bridge_merge_message.
Message representing the merge of two bridges.

References ao2_ref, ast_assert, AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_merge_message_type(), ast_bridge_topic_all(), ast_test_flag, bridge_merge_message_create(), ast_bridge::feature_flags, NULL, stasis_message_create(), and stasis_publish().

Referenced by bridge_do_merge().

◆ ast_bridge_publish_state()

void ast_bridge_publish_state ( struct ast_bridge bridge)

Publish the state of a bridge.

Since
12
Precondition
Bridge is locked
Parameters
bridgeThe bridge for which to publish state

Definition at line 393 of file stasis_bridges.c.

394{
395 struct ast_bridge_snapshot *new_snapshot;
397 struct stasis_message *msg;
398
399 ast_assert(bridge != NULL);
400
401 new_snapshot = ast_bridge_snapshot_create(bridge);
402 if (!new_snapshot) {
403 return;
404 }
405
407 /* There may not have been an old snapshot */
409 bridge->current_snapshot = new_snapshot;
410 if (!update) {
411 return;
412 }
413
415 ao2_ref(update, -1);
416 if (!msg) {
417 return;
418 }
419
420 stasis_publish(ast_bridge_topic(bridge), msg);
421 ao2_ref(msg, -1);
422}
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition codec_g726.c:367
static struct ast_bridge_snapshot_update * bridge_snapshot_update_create(struct ast_bridge_snapshot *old, struct ast_bridge_snapshot *new)
struct stasis_message_type * ast_bridge_snapshot_type(void)
Message type for ast_bridge_snapshot.

References ao2_cleanup, ao2_ref, ast_assert, ast_bridge_snapshot_create(), ast_bridge_snapshot_type(), ast_bridge_topic(), bridge_snapshot_update_create(), ast_bridge::current_snapshot, NULL, stasis_message_create(), stasis_publish(), and update().

Referenced by ast_bridge_set_single_src_video_mode(), ast_bridge_update_talker_src_video_mode(), bridge_reconfigured(), bridge_register(), and stasis_app_bridge_set_var_reportable().

◆ ast_bridge_snapshot_create()

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.

Since
12
Precondition
Bridge is locked
Parameters
bridgeThe bridge from which to generate a snapshot
Returns
AO2 refcounted snapshot on success
Return values
NULLon error

Definition at line 232 of file stasis_bridges.c.

233{
234 struct ast_bridge_snapshot *snapshot;
235 struct ast_bridge_channel *bridge_channel;
236
238 return NULL;
239 }
240
241 snapshot = ao2_alloc_options(sizeof(*snapshot), bridge_snapshot_dtor,
243 if (!snapshot) {
244 return NULL;
245 }
246
247 if (ast_string_field_init(snapshot, 128)) {
248 ao2_ref(snapshot, -1);
249
250 return NULL;
251 }
252
254 if (!snapshot->channels) {
255 ao2_ref(snapshot, -1);
256
257 return NULL;
258 }
259
260 AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
261 if (ast_str_container_add(snapshot->channels,
262 ast_channel_uniqueid(bridge_channel->chan))) {
263 ao2_ref(snapshot, -1);
264
265 return NULL;
266 }
267 }
268
269 ast_string_field_set(snapshot, uniqueid, bridge->uniqueid);
270 ast_string_field_set(snapshot, technology, bridge->technology->name);
271 ast_string_field_set(snapshot, subclass, bridge->v_table->name);
272 ast_string_field_set(snapshot, creator, bridge->creator);
274
277 snapshot->num_channels = bridge->num_channels;
278 snapshot->num_active = bridge->num_active;
279 snapshot->creationtime = bridge->creationtime;
283 ast_string_field_set(snapshot, video_source_id,
285 } else if (snapshot->video_mode == AST_BRIDGE_VIDEO_MODE_TALKER_SRC
287 ast_string_field_set(snapshot, video_source_id,
289 }
290
292
293 return snapshot;
294}
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition astobj2.h:367
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition astobj2.h:404
struct varshead * ast_bridge_get_ari_reportable_variables(struct ast_bridge *bridge)
Get a list of variables that should be included in ARI events for this bridge.
Definition bridge.c:1385
@ AST_BRIDGE_VIDEO_MODE_SINGLE_SRC
Definition bridge.h:106
@ AST_BRIDGE_VIDEO_MODE_TALKER_SRC
Definition bridge.h:109
static const char name[]
Definition format_mp3.c:68
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define SNAPSHOT_CHANNELS_BUCKETS
static void bridge_snapshot_dtor(void *obj)
Destructor for bridge snapshots.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_str_container_alloc(buckets)
Allocates a hash container for bare strings.
Definition strings.h:1365
int ast_str_container_add(struct ao2_container *str_container, const char *add)
Adds a string to a string container allocated by ast_str_container_alloc.
Definition strings.c:205
Structure that contains information regarding a channel in a bridge.
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_channel * chan
struct ast_bridge_channel::@201 entry
const char * name
Definition bridge.h:263
uint32_t capabilities
Definition bridge.h:339
enum ast_bridge_video_mode_type video_mode
Definition bridge.h:345
struct timeval creationtime
Definition bridge.h:347
struct varshead * bridgevars
Definition bridge.h:349
unsigned int num_active
Definition bridge.h:343
unsigned int num_channels
Definition bridge.h:341
struct ao2_container * channels
Definition bridge.h:335
struct ast_flags feature_flags
Definition bridge.h:337
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::@198 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_vsrc
Definition bridge.h:127
struct ast_bridge_softmix softmix
Definition bridge.h:373
struct timeval creationtime
Definition bridge.h:414
const struct ast_bridge_methods * v_table
Definition bridge.h:357
unsigned int num_active
Definition bridge.h:381
const ast_string_field creator
Definition bridge.h:407
struct ast_bridge_channels_list channels
Definition bridge.h:369
unsigned int num_channels
Definition bridge.h:379
struct ast_bridge_technology * technology
Definition bridge.h:361
const ast_string_field name
Definition bridge.h:407

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_get_ari_reportable_variables(), AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, ast_channel_uniqueid(), AST_LIST_TRAVERSE, ast_str_container_add(), ast_str_container_alloc, ast_string_field_init, ast_string_field_set, ast_test_flag, ast_bridge_channel::bridge, bridge_snapshot_dtor(), ast_bridge_snapshot::bridgevars, ast_bridge_snapshot::capabilities, ast_bridge_technology::capabilities, ast_bridge_channel::chan, ast_bridge_video_single_src_data::chan_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge_snapshot::channels, ast_bridge::channels, ast_bridge_snapshot::creationtime, ast_bridge::creationtime, ast_bridge::creator, ast_bridge_channel::entry, ast_bridge_snapshot::feature_flags, ast_bridge::feature_flags, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, name, ast_bridge_methods::name, ast_bridge::name, ast_bridge_technology::name, NULL, ast_bridge_snapshot::num_active, ast_bridge::num_active, ast_bridge_snapshot::num_channels, ast_bridge::num_channels, ast_bridge_video_mode::single_src_data, SNAPSHOT_CHANNELS_BUCKETS, ast_bridge::softmix, ast_bridge_video_mode::talker_src_data, ast_bridge::technology, ast_bridge::uniqueid, ast_bridge::v_table, ast_bridge_softmix::video_mode, and ast_bridge_snapshot::video_mode.

Referenced by ast_ari_bridges_create(), ast_ari_bridges_create_with_id(), ast_bridge_blob_create(), ast_bridge_publish_state(), ast_bridge_transfer_blind(), AST_TEST_DEFINE(), bridge_channel_snapshot_pair_init(), bridge_merge_message_create(), bridge_topics_destroy(), and send_conf_stasis_snapshots().

◆ ast_bridge_snapshot_to_json()

struct ast_json * ast_bridge_snapshot_to_json ( const struct ast_bridge_snapshot snapshot,
const struct stasis_message_sanitizer sanitize 
)

Build a JSON object from a ast_bridge_snapshot.

Parameters
snapshotThe bridge snapshot to convert to JSON
sanitizeThe message sanitizer to use on the snapshot
Returns
JSON object representing bridge snapshot.
Return values
NULLon error

Definition at line 755 of file stasis_bridges.c.

758{
759 struct ast_json *json_bridge;
760 struct ast_json *json_channels;
761
762 if (snapshot == NULL) {
763 return NULL;
764 }
765
766 json_channels = container_to_json_array(snapshot->channels, sanitize);
767 if (!json_channels) {
768 return NULL;
769 }
770
771 json_bridge = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: o, s: o, s: s}",
772 "id", snapshot->uniqueid,
773 "technology", snapshot->technology,
774 "bridge_type", capability2str(snapshot->capabilities),
775 "bridge_class", snapshot->subclass,
776 "creator", snapshot->creator,
777 "name", snapshot->name,
778 "channels", json_channels,
779 "creationtime", ast_json_timeval(snapshot->creationtime, NULL),
780 "video_mode", ast_bridge_video_mode_to_string(snapshot->video_mode));
781 if (!json_bridge) {
782 return NULL;
783 }
784
786 && !ast_strlen_zero(snapshot->video_source_id)) {
787 ast_json_object_set(json_bridge, "video_source_id",
789 }
790
791 if (snapshot->bridgevars && !AST_LIST_EMPTY(snapshot->bridgevars)) {
792 ast_json_object_set(json_bridge, "bridgevars",
794 }
795
796 return json_bridge;
797}
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.
Definition bridge.c:4160
@ AST_BRIDGE_VIDEO_MODE_NONE
Definition bridge.h:104
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition json.c:278
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
Definition json.c:670
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition json.c:414
struct ast_json * ast_json_channel_vars(struct varshead *channelvars)
Construct a JSON object from a ast_var_t list.
Definition json.c:941
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
static const char * capability2str(uint32_t capabilities)
static struct ast_json * container_to_json_array(struct ao2_container *items, const struct stasis_message_sanitizer *sanitize)
const ast_string_field video_source_id
Definition bridge.h:332
const ast_string_field creator
Definition bridge.h:332
const ast_string_field technology
Definition bridge.h:332
const ast_string_field name
Definition bridge.h:332
const ast_string_field subclass
Definition bridge.h:332

References AST_BRIDGE_VIDEO_MODE_NONE, ast_bridge_video_mode_to_string(), ast_json_channel_vars(), ast_json_object_set(), ast_json_pack(), ast_json_string_create(), ast_json_timeval(), AST_LIST_EMPTY, ast_strlen_zero(), ast_bridge_snapshot::bridgevars, ast_bridge_snapshot::capabilities, capability2str(), ast_bridge_snapshot::channels, container_to_json_array(), ast_bridge_snapshot::creationtime, ast_bridge_snapshot::creator, ast_bridge_snapshot::name, NULL, ast_bridge_snapshot::subclass, ast_bridge_snapshot::technology, ast_bridge_snapshot::uniqueid, ast_bridge_snapshot::video_mode, and ast_bridge_snapshot::video_source_id.

Referenced by ari_transfer_to_json(), ast_ari_bridges_create(), ast_ari_bridges_create_with_id(), ast_ari_bridges_get(), ast_ari_bridges_list(), ast_bridge_merge_message_to_json(), attended_transfer_to_json(), blind_transfer_to_json(), bridge_to_json(), multi_user_event_to_json(), simple_bridge_channel_event(), and simple_bridge_event().

◆ ast_bridge_snapshot_type()

struct stasis_message_type * ast_bridge_snapshot_type ( void  )

◆ ast_bridge_topic()

struct stasis_topic * ast_bridge_topic ( struct ast_bridge bridge)

A topic which publishes the events for a particular bridge.

Since
12

If the given bridge is NULL, ast_bridge_topic_all() is returned.

Parameters
bridgeBridge for which to get a topic or NULL.
Returns
Topic for bridge's events.
Return values
ast_bridge_topic_all()if bridge is NULL.

Definition at line 192 of file stasis_bridges.c.

193{
194 if (!bridge) {
195 return ast_bridge_topic_all();
196 }
197
198 return bridge->topic;
199}
struct stasis_topic * topic
Definition bridge.h:365

References ast_bridge_topic_all(), and ast_bridge::topic.

Referenced by ari_bridges_play_new(), ast_ari_bridges_record(), ast_bridge_publish_enter(), ast_bridge_publish_leave(), ast_bridge_publish_state(), bridge_base_init(), bridge_publish_state_from_blob(), bridge_topics_destroy(), forwards_create_bridge(), send_conf_stasis(), and send_conf_stasis_snapshots().

◆ ast_bridge_topic_all()

struct stasis_topic * ast_bridge_topic_all ( void  )

A topic which publishes the events for all bridges.

Since
12
Returns
Topic for all bridge events.

Definition at line 187 of file stasis_bridges.c.

188{
189 return bridge_topic_all;
190}
static struct stasis_topic * bridge_topic_all

References bridge_topic_all.

Referenced by app_create(), ast_bridge_publish_attended_transfer(), ast_bridge_publish_blind_transfer(), ast_bridge_publish_merge(), ast_bridge_topic(), create_subscriptions(), create_subscriptions(), manager_bridging_init(), manager_confbridge_init(), refer_blind_callback(), and setup_stasis_subs().

◆ ast_bridge_topic_exists()

int ast_bridge_topic_exists ( const char *  uniqueid)

Check if a stasis topic exists for a bridge uniqueid.

Parameters
uniqueidThe uniqueid to test
Return values
1if the topic exists
0if the topic does not exist

Definition at line 201 of file stasis_bridges.c.

202{
203 char *topic_name;
204 int ret;
205
206 if (ast_strlen_zero(uniqueid)) {
207 return 0;
208 }
209
210 ret = ast_asprintf(&topic_name, "bridge:%s", uniqueid);
211 if (ret < 0) {
212 return 0;
213 }
215 ast_free(topic_name);
216
217 return ret;
218}
#define ast_free(a)
Definition astmm.h:180
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition astmm.h:267
int stasis_topic_pool_topic_exists(const struct stasis_topic_pool *pool, const char *topic_name)
Check if a topic exists in a pool.
Definition stasis.c:2139
static struct stasis_topic_pool * bridge_topic_pool

References ast_asprintf, ast_free, ast_strlen_zero(), bridge_topic_pool, and stasis_topic_pool_topic_exists().

Referenced by ast_ari_bridges_create(), ast_ari_bridges_create_with_id(), and bridge_base_init().

◆ ast_channel_entered_bridge_type()

struct stasis_message_type * ast_channel_entered_bridge_type ( void  )

Message type for ast_channel enter bridge blob messages.

Since
12
Returns
Message type for ast_channel enter bridge blob messages.

Referenced by ast_bridge_publish_enter(), ast_stasis_bridging_init(), create_routes(), load_module(), manager_bridging_init(), refer_blind_callback(), refer_progress_bridge(), setup_stasis_subs(), and stasis_bridging_cleanup().

◆ ast_channel_left_bridge_type()

struct stasis_message_type * ast_channel_left_bridge_type ( void  )

Message type for ast_channel leave bridge blob messages.

Since
12
Returns
Message type for ast_channel leave bridge blob messages.

Referenced by ast_bridge_publish_leave(), ast_stasis_bridging_init(), create_routes(), load_module(), manager_bridging_init(), and stasis_bridging_cleanup().

◆ ast_stasis_bridging_init()

int ast_stasis_bridging_init ( void  )

Definition at line 1455 of file stasis_bridges.c.

1456{
1457 int res = 0;
1458
1460
1461 bridge_topic_all = stasis_topic_create("bridge:all");
1462 if (!bridge_topic_all) {
1463 return -1;
1464 }
1466 if (!bridge_topic_pool) {
1467 return -1;
1468 }
1469
1476
1477 return res;
1478}
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition clicompat.c:19
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition stasis.c:684
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition stasis.h:1524
struct stasis_topic_pool * stasis_topic_pool_create(struct stasis_topic *pooled_topic)
Create a topic pool that routes messages from dynamically generated topics to the given topic.
Definition stasis.c:1929
static void stasis_bridging_cleanup(void)

References ast_attended_transfer_type(), ast_blind_transfer_type(), ast_bridge_merge_message_type(), ast_bridge_snapshot_type(), ast_channel_entered_bridge_type(), ast_channel_left_bridge_type(), ast_register_cleanup(), bridge_topic_all, bridge_topic_pool, stasis_bridging_cleanup(), STASIS_MESSAGE_TYPE_INIT, stasis_topic_create(), and stasis_topic_pool_create().

Referenced by ast_bridging_init().

◆ bridge_topics_destroy()

void bridge_topics_destroy ( struct ast_bridge bridge)

Definition at line 352 of file stasis_bridges.c.

353{
355 struct stasis_message *msg;
356
357 ast_assert(bridge != NULL);
358 ast_debug(1, "Bridge " BRIDGE_PRINTF_SPEC ": destroying topics\n",
359 BRIDGE_PRINTF_VARS(bridge));
360
361 if (!bridge->topic) {
362 ast_log(LOG_WARNING, "Bridge " BRIDGE_PRINTF_SPEC " topic is NULL\n",
363 BRIDGE_PRINTF_VARS(bridge));
364 return;
365 }
366
367 if (!bridge->current_snapshot) {
369 if (!bridge->current_snapshot) {
370 return;
371 }
372 }
373
375 if (!update) {
376 return;
377 }
378
380 ao2_ref(update, -1);
381 if (!msg) {
382 return;
383 }
384
385 stasis_publish(ast_bridge_topic(bridge), msg);
386 ao2_ref(msg, -1);
387
389 ao2_cleanup(bridge->topic);
390 bridge->topic = NULL;
391}
#define ast_log
Definition astobj2.c:42
#define BRIDGE_PRINTF_VARS(bridge)
Definition bridge.h:80
#define BRIDGE_PRINTF_SPEC
Definition bridge.h:79
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
void stasis_topic_pool_delete_topic(struct stasis_topic_pool *pool, const char *topic_name)
Delete a topic from the topic pool.
Definition stasis.c:1960
const char * stasis_topic_name(const struct stasis_topic *topic)
Return the name of a topic.
Definition stasis.c:694

References ao2_cleanup, ao2_ref, ast_assert, ast_bridge_snapshot_create(), ast_bridge_snapshot_type(), ast_bridge_topic(), ast_debug, ast_log, BRIDGE_PRINTF_SPEC, BRIDGE_PRINTF_VARS, bridge_snapshot_update_create(), bridge_topic_pool, ast_bridge::current_snapshot, LOG_WARNING, NULL, stasis_message_create(), stasis_publish(), stasis_topic_name(), stasis_topic_pool_delete_topic(), ast_bridge::topic, and update().

Referenced by destroy_bridge().

◆ bridge_topics_init()

int bridge_topics_init ( struct ast_bridge bridge)

Definition at line 327 of file stasis_bridges.c.

328{
329 char *topic_name;
330 int ret;
331
332 if (ast_strlen_zero(bridge->uniqueid)) {
333 ast_log(LOG_ERROR, "Bridge id initialization required\n");
334 return -1;
335 }
336
337 ret = ast_asprintf(&topic_name, "bridge:%s", bridge->uniqueid);
338 if (ret < 0) {
339 return -1;
340 }
341
343 ast_free(topic_name);
344 if (!bridge->topic) {
345 return -1;
346 }
347 ao2_bump(bridge->topic);
348
349 return 0;
350}
#define LOG_ERROR
struct stasis_topic * stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name)
Find or create a topic in the pool.
Definition stasis.c:1996

References ao2_bump, ast_asprintf, ast_free, ast_log, ast_strlen_zero(), bridge_topic_pool, LOG_ERROR, stasis_topic_pool_get_topic(), ast_bridge::topic, and ast_bridge::uniqueid.

Referenced by bridge_base_init().