Asterisk - The Open Source Telephony Project  21.4.1
Macros | Functions | Variables
stasis_bridges.c File Reference

Stasis Messages and Data Types for Bridge Objects. More...

#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_cache_pattern.h"
#include "asterisk/channel.h"
#include "asterisk/stasis_bridges.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_technology.h"

Go to the source code of this file.

Macros

#define SNAPSHOT_CHANNELS_BUCKETS   1
 

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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
struct stasis_messageast_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. More...
 
struct stasis_messageast_bridge_blob_create_from_snapshots (struct stasis_message_type *message_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. More...
 
struct ast_bridge_snapshotast_bridge_get_snapshot (struct ast_bridge *bridge)
 Returns the current snapshot for the bridge. More...
 
struct ast_bridge_snapshotast_bridge_get_snapshot_by_uniqueid (const char *uniqueid)
 Returns the current snapshot for the bridge. More...
 
static struct ast_jsonast_bridge_merge_message_to_json (struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
 
void ast_bridge_publish_attended_transfer (struct ast_attended_transfer_message *transfer_msg)
 Publish an attended transfer. More...
 
void ast_bridge_publish_blind_transfer (struct ast_blind_transfer_message *transfer_message)
 Publish a blind transfer event. More...
 
void ast_bridge_publish_enter (struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
 Publish a bridge channel enter event. More...
 
void ast_bridge_publish_leave (struct ast_bridge *bridge, struct ast_channel *chan)
 Publish a bridge channel leave event. More...
 
void ast_bridge_publish_merge (struct ast_bridge *to, struct ast_bridge *from)
 Publish a bridge merge. More...
 
void ast_bridge_publish_state (struct ast_bridge *bridge)
 Publish the state of a bridge. More...
 
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. More...
 
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. More...
 
struct stasis_topicast_bridge_topic (struct ast_bridge *bridge)
 A topic which publishes the events for a particular bridge. More...
 
struct stasis_topicast_bridge_topic_all (void)
 A topic which publishes the events for all bridges. More...
 
static struct ast_jsonast_channel_entered_bridge_to_json (struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_jsonast_channel_left_bridge_to_json (struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
 
int ast_stasis_bridging_init (void)
 
static void attended_transfer_dtor (void *obj)
 
static struct ast_manager_event_blobattended_transfer_to_ami (struct stasis_message *message)
 
static struct ast_jsonattended_transfer_to_json (struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
 
static void blind_transfer_dtor (void *obj)
 
static struct ast_manager_event_blobblind_transfer_to_ami (struct stasis_message *message)
 
static struct ast_jsonblind_transfer_to_json (struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
 
static void bridge_blob_dtor (void *obj)
 
static void bridge_channel_snapshot_pair_cleanup (struct ast_bridge_channel_snapshot_pair *pair)
 
static int bridge_channel_snapshot_pair_init (struct ast_channel *channel, struct ast_bridge *bridge, struct ast_bridge_channel_snapshot_pair *snapshot_pair)
 
static struct ast_bridge_merge_messagebridge_merge_message_create (struct ast_bridge *to, struct ast_bridge *from)
 Bridge merge message creation helper.
 
static void bridge_merge_message_dtor (void *obj)
 Destructor for bridge merge messages.
 
static void bridge_publish_state_from_blob (struct ast_bridge *bridge, struct ast_bridge_blob *obj)
 
static void bridge_snapshot_dtor (void *obj)
 Destructor for bridge snapshots.
 
static struct ast_bridge_snapshot_updatebridge_snapshot_update_create (struct ast_bridge_snapshot *old, struct ast_bridge_snapshot *new)
 
static void bridge_snapshot_update_dtor (void *obj)
 
void bridge_topics_destroy (struct ast_bridge *bridge)
 
int bridge_topics_init (struct ast_bridge *bridge)
 
static const char * capability2str (uint32_t capabilities)
 
static struct ast_jsoncontainer_to_json_array (struct ao2_container *items, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_jsonsimple_bridge_channel_event (const char *type, struct ast_bridge_snapshot *bridge_snapshot, struct ast_channel_snapshot *channel_snapshot, const struct timeval *tv, const struct stasis_message_sanitizer *sanitize)
 
static void stasis_bridging_cleanup (void)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_bridge_snapshot_type)
 Define bridge message types.
 
 STASIS_MESSAGE_TYPE_DEFN (ast_bridge_merge_message_type,.to_json=ast_bridge_merge_message_to_json)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_entered_bridge_type,.to_json=ast_channel_entered_bridge_to_json)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_left_bridge_type,.to_json=ast_channel_left_bridge_to_json)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_blind_transfer_type,.to_json=blind_transfer_to_json,.to_ami=blind_transfer_to_ami)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_attended_transfer_type,.to_json=attended_transfer_to_json,.to_ami=attended_transfer_to_ami)
 

Variables

static struct stasis_topicbridge_topic_all
 
static struct stasis_topic_poolbridge_topic_pool
 
static const char * result_strs []
 

Detailed Description

Stasis Messages and Data Types for Bridge Objects.

Author
Kinsey Moore kmoor.nosp@m.e@di.nosp@m.gium..nosp@m.com

Definition in file stasis_bridges.c.

Function Documentation

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 1313 of file stasis_bridges.c.

References ast_attended_transfer_message::app, ast_channel_snapshot_get_latest(), ast_copy_string(), ast_attended_transfer_message::dest_type, and ast_attended_transfer_message::replace_channel.

Referenced by ast_bridge_transfer_attended(), and attended_transfer_bridge().

1315 {
1316  transfer_msg->dest_type = replace_channel ? AST_ATTENDED_TRANSFER_DEST_LOCAL_APP : AST_ATTENDED_TRANSFER_DEST_APP;
1317 
1318  if (replace_channel) {
1319  transfer_msg->replace_channel = ast_channel_snapshot_get_latest(ast_channel_uniqueid(replace_channel));
1320  if (!transfer_msg->replace_channel) {
1321  return -1;
1322  }
1323  }
1324 
1325  ast_copy_string(transfer_msg->dest.app, app, sizeof(transfer_msg->dest.app));
1326 
1327  return 0;
1328 }
struct ast_channel_snapshot * replace_channel
enum ast_attended_transfer_dest_type dest_type
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
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 1330 of file stasis_bridges.c.

References ast_channel_snapshot_get_latest(), ast_attended_transfer_message::dest_type, and ast_attended_transfer_message::links.

Referenced by attended_transfer_bridge().

1332 {
1333  int i;
1334 
1335  transfer_msg->dest_type = AST_ATTENDED_TRANSFER_DEST_LINK;
1336  for (i = 0; i < 2; ++i) {
1337  transfer_msg->dest.links[i] = ast_channel_snapshot_get_latest(ast_channel_uniqueid(locals[i]));
1338  if (!transfer_msg->dest.links[i]) {
1339  return -1;
1340  }
1341  }
1342 
1343  return 0;
1344 }
struct ast_channel_snapshot * links[2]
enum ast_attended_transfer_dest_type dest_type
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...
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 1283 of file stasis_bridges.c.

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

Referenced by publish_transfer_success().

1285 {
1286  transfer_msg->dest_type = AST_ATTENDED_TRANSFER_DEST_BRIDGE_MERGE;
1287  ast_copy_string(transfer_msg->dest.bridge, final_bridge->uniqueid,
1288  sizeof(transfer_msg->dest.bridge));
1289 
1290  return 0;
1291 }
const ast_string_field uniqueid
Definition: bridge.h:401
char bridge[AST_UUID_STR_LEN]
enum ast_attended_transfer_dest_type dest_type
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
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 1293 of file stasis_bridges.c.

References ast_channel_snapshot::base, 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_channel_snapshot_base::uniqueid, ast_bridge_snapshot::uniqueid, and ast_bridge::uniqueid.

Referenced by publish_transfer_threeway().

1295 {
1296  transfer_msg->dest_type = AST_ATTENDED_TRANSFER_DEST_THREEWAY;
1297 
1298  if (!strcmp(ast_channel_uniqueid(survivor_channel), transfer_msg->to_transferee.channel_snapshot->base->uniqueid)) {
1299  transfer_msg->dest.threeway.channel_snapshot = transfer_msg->to_transferee.channel_snapshot;
1300  } else {
1301  transfer_msg->dest.threeway.channel_snapshot = transfer_msg->to_transfer_target.channel_snapshot;
1302  }
1303 
1304  if (!strcmp(survivor_bridge->uniqueid, transfer_msg->to_transferee.bridge_snapshot->uniqueid)) {
1305  transfer_msg->dest.threeway.bridge_snapshot = transfer_msg->to_transferee.bridge_snapshot;
1306  } else {
1307  transfer_msg->dest.threeway.bridge_snapshot = transfer_msg->to_transfer_target.bridge_snapshot;
1308  }
1309 
1310  return 0;
1311 }
struct ast_channel_snapshot_base * base
const ast_string_field uniqueid
Definition: bridge.h:401
const ast_string_field uniqueid
struct ast_bridge_channel_snapshot_pair to_transferee
struct ast_bridge_channel_snapshot_pair to_transfer_target
enum ast_attended_transfer_dest_type dest_type
struct ast_bridge_channel_snapshot_pair threeway
const ast_string_field uniqueid
Definition: bridge.h:328
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 1226 of file stasis_bridges.c.

References ast_bridge_peer(), ast_channel_snapshot_get_latest(), 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().

1230 {
1231  struct ast_attended_transfer_message *transfer_msg;
1232 
1233  transfer_msg = ao2_alloc(sizeof(*transfer_msg), attended_transfer_dtor);
1234  if (!transfer_msg) {
1235  return NULL;
1236  }
1237 
1238  if (bridge_channel_snapshot_pair_init(to_transferee, transferee_bridge, &transfer_msg->to_transferee) ||
1239  bridge_channel_snapshot_pair_init(to_transfer_target, target_bridge, &transfer_msg->to_transfer_target)) {
1240  ao2_cleanup(transfer_msg);
1241  return NULL;
1242  }
1243 
1244  if (transferee) {
1245  transfer_msg->transferee = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transferee));
1246  if (!transfer_msg->transferee) {
1247  ao2_cleanup(transfer_msg);
1248  return NULL;
1249  }
1250  } else if (transferee_bridge) {
1251  transferee = ast_bridge_peer(transferee_bridge, to_transferee);
1252  if (transferee) {
1253  transfer_msg->transferee = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transferee));
1254  ao2_cleanup(transferee);
1255  if (!transfer_msg->transferee) {
1256  ao2_cleanup(transfer_msg);
1257  return NULL;
1258  }
1259  }
1260  }
1261 
1262  if (transfer_target) {
1263  transfer_msg->target = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transfer_target));
1264  if (!transfer_msg->target) {
1265  ao2_cleanup(transfer_msg);
1266  return NULL;
1267  }
1268  } else if (target_bridge) {
1269  transfer_target = ast_bridge_peer(target_bridge, to_transfer_target);
1270  if (transfer_target) {
1271  transfer_msg->target = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transfer_target));
1272  ao2_cleanup(transfer_target);
1273  if (!transfer_msg->target) {
1274  ao2_cleanup(transfer_msg);
1275  return NULL;
1276  }
1277  }
1278  }
1279 
1280  return transfer_msg;
1281 }
Message representing attended transfer.
struct ast_channel_snapshot * target
struct ast_bridge_channel_snapshot_pair to_transferee
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: bridge.c:4075
struct ast_bridge_channel_snapshot_pair to_transfer_target
struct ast_channel_snapshot * transferee
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...
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 929 of file stasis_bridges.c.

References ast_channel_snapshot_get_latest(), ast_copy_string(), ast_blind_transfer_message::context, ast_blind_transfer_message::exten, ast_blind_transfer_message::is_external, and ast_blind_transfer_message::transferer.

Referenced by ast_bridge_transfer_blind().

931 {
932  struct ast_blind_transfer_message *msg;
933 
934  msg = ao2_alloc(sizeof(*msg), blind_transfer_dtor);
935  if (!msg) {
936  return NULL;
937  }
938 
939  msg->transferer = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transferer));
940  if (!msg->transferer) {
941  ao2_cleanup(msg);
942  return NULL;
943  }
944 
945  msg->is_external = is_external;
946  ast_copy_string(msg->context, context, sizeof(msg->context));
947  ast_copy_string(msg->exten, exten, sizeof(msg->exten));
948 
949  return msg;
950 }
char exten[AST_MAX_EXTENSION]
Message published during a blind transfer.
struct ast_channel_snapshot * transferer
char context[AST_MAX_CONTEXT]
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
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 500 of file stasis_bridges.c.

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

Referenced by ast_bridge_publish_enter(), and ast_bridge_publish_leave().

505 {
506  struct ast_bridge_blob *obj;
507  struct stasis_message *msg;
508 
509  if (!message_type) {
510  return NULL;
511  }
512 
513  obj = ao2_alloc(sizeof(*obj), bridge_blob_dtor);
514  if (!obj) {
515  return NULL;
516  }
517 
518  if (bridge) {
519  obj->bridge = ast_bridge_snapshot_create(bridge);
520  if (obj->bridge == NULL) {
521  ao2_ref(obj, -1);
522 
523  return NULL;
524  }
525  }
526 
527  if (chan) {
528  obj->channel = ast_channel_snapshot_get_latest(ast_channel_uniqueid(chan));
529  if (obj->channel == NULL) {
530  ao2_ref(obj, -1);
531 
532  return NULL;
533  }
534  }
535 
536  if (blob) {
537  obj->blob = ast_json_ref(blob);
538  }
539 
540  msg = stasis_message_create(message_type, obj);
541  ao2_ref(obj, -1);
542 
543  return msg;
544 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
struct ast_channel_snapshot * channel
struct ast_json * blob
struct ast_bridge_snapshot * bridge
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
Blob of data associated with a bridge.
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...
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...
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 546 of file stasis_bridges.c.

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

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

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

Referenced by ast_ari_bridges_list().

1379 {
1380  struct ast_bridge_snapshot *snapshot;
1381 
1382  if (!bridge) {
1383  return NULL;
1384  }
1385  ast_bridge_lock(bridge);
1386  snapshot = ao2_bump(bridge->current_snapshot);
1387  ast_bridge_unlock(bridge);
1388 
1389  return snapshot;
1390 }
Structure that contains a snapshot of information about a bridge.
Definition: bridge.h:314
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
struct ast_bridge_snapshot * current_snapshot
Definition: bridge.h:406
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
struct ast_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 1359 of file stasis_bridges.c.

References ao2_bump, ao2_ref, ast_bridge_find_by_id(), ast_bridge_lock, ast_bridge_unlock, and ast_bridge::current_snapshot.

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

1360 {
1361  struct ast_bridge *bridge;
1362  struct ast_bridge_snapshot *snapshot;
1363 
1364  ast_assert(!ast_strlen_zero(uniqueid));
1365 
1366  bridge = ast_bridge_find_by_id(uniqueid);
1367  if (!bridge) {
1368  return NULL;
1369  }
1370  ast_bridge_lock(bridge);
1371  snapshot = ao2_bump(bridge->current_snapshot);
1372  ast_bridge_unlock(bridge);
1373  ao2_ref(bridge, -1);
1374 
1375  return snapshot;
1376 }
struct ast_bridge * ast_bridge_find_by_id(const char *bridge_id)
Find bridge by id.
Definition: bridge.c:5012
Structure that contains a snapshot of information about a bridge.
Definition: bridge.h:314
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct ast_bridge_snapshot * current_snapshot
Definition: bridge.h:406
Structure that contains information about a bridge.
Definition: bridge.h:349
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
const ast_string_field uniqueid
Definition: bridge.h:328
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
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 1346 of file stasis_bridges.c.

References ao2_ref, 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().

1347 {
1348  struct stasis_message *msg;
1349 
1350  msg = stasis_message_create(ast_attended_transfer_type(), transfer_msg);
1351  if (!msg) {
1352  return;
1353  }
1354 
1356  ao2_ref(msg, -1);
1357 }
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
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 953 of file stasis_bridges.c.

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

Referenced by ast_bridge_transfer_blind().

954 {
955  struct stasis_message *stasis;
956 
957  stasis = stasis_message_create(ast_blind_transfer_type(), transfer_message);
958  if (!stasis) {
959  return;
960  }
961 
963 
964  ao2_cleanup(stasis);
965 }
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
static const char * stasis
Dialplan application name.
Definition: app_stasis.c:80
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 582 of file stasis_bridges.c.

References ao2_ref, ast_bridge_blob_create(), AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic(), ast_json_pack(), ast_json_unref(), ast_bridge::feature_flags, stasis_message_data(), and stasis_publish().

584 {
585  struct stasis_message *msg;
586  struct ast_json *blob = NULL;
587 
588  if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_INVISIBLE)) {
589  return;
590  }
591 
592  if (swap) {
593  blob = ast_json_pack("{s: s}", "swap", ast_channel_uniqueid(swap));
594  if (!blob) {
595  return;
596  }
597  }
598 
599  msg = ast_bridge_blob_create(ast_channel_entered_bridge_type(), bridge, chan, blob);
600  ast_json_unref(blob);
601  if (!msg) {
602  return;
603  }
604 
605  /* enter blob first, then state */
606  stasis_publish(ast_bridge_topic(bridge), msg);
607  bridge_publish_state_from_blob(bridge, stasis_message_data(msg));
608  ao2_ref(msg, -1);
609 }
struct ast_flags feature_flags
Definition: bridge.h:369
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
Abstract JSON element (object, array, string, int, ...).
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.
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 611 of file stasis_bridges.c.

References ao2_ref, ast_bridge_blob_create(), AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic(), ast_bridge::feature_flags, stasis_message_data(), and stasis_publish().

612 {
613  struct stasis_message *msg;
614 
615  if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_INVISIBLE)) {
616  return;
617  }
618  msg = ast_bridge_blob_create(ast_channel_left_bridge_type(), bridge, chan, NULL);
619  if (!msg) {
620  return;
621  }
622 
623  /* state first, then leave blob (opposite of enter, preserves nesting of events) */
624  bridge_publish_state_from_blob(bridge, stasis_message_data(msg));
625  stasis_publish(ast_bridge_topic(bridge), msg);
626  ao2_ref(msg, -1);
627 }
struct ast_flags feature_flags
Definition: bridge.h:369
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
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.
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 460 of file stasis_bridges.c.

References ao2_ref, AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_topic_all(), bridge_merge_message_create(), ast_bridge::feature_flags, stasis_message_create(), and stasis_publish().

461 {
462  struct ast_bridge_merge_message *merge_msg;
463  struct stasis_message *msg;
464 
465  if (!ast_bridge_merge_message_type()) {
466  return;
467  }
468 
469  ast_assert(to != NULL);
470  ast_assert(from != NULL);
471  ast_assert(ast_test_flag(&to->feature_flags, AST_BRIDGE_FLAG_INVISIBLE) == 0);
472  ast_assert(ast_test_flag(&from->feature_flags, AST_BRIDGE_FLAG_INVISIBLE) == 0);
473 
474  merge_msg = bridge_merge_message_create(to, from);
475  if (!merge_msg) {
476  return;
477  }
478 
479  msg = stasis_message_create(ast_bridge_merge_message_type(), merge_msg);
480  ao2_ref(merge_msg, -1);
481  if (!msg) {
482  return;
483  }
484 
486  ao2_ref(msg, -1);
487 }
struct ast_flags feature_flags
Definition: bridge.h:369
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_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
Message representing the merge of two bridges.
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 350 of file stasis_bridges.c.

References ao2_ref, ast_bridge_snapshot_create(), ast_bridge_topic(), ast_bridge::current_snapshot, stasis_message_create(), and stasis_publish().

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

351 {
352  struct ast_bridge_snapshot *new_snapshot;
353  struct ast_bridge_snapshot_update *update;
354  struct stasis_message *msg;
355 
356  ast_assert(bridge != NULL);
357 
358  new_snapshot = ast_bridge_snapshot_create(bridge);
359  if (!new_snapshot) {
360  return;
361  }
362 
363  update = bridge_snapshot_update_create(bridge->current_snapshot, new_snapshot);
364  /* There may not have been an old snapshot */
365  ao2_cleanup(bridge->current_snapshot);
366  bridge->current_snapshot = new_snapshot;
367  if (!update) {
368  return;
369  }
370 
371  msg = stasis_message_create(ast_bridge_snapshot_type(), update);
372  ao2_ref(update, -1);
373  if (!msg) {
374  return;
375  }
376 
377  stasis_publish(ast_bridge_topic(bridge), msg);
378  ao2_ref(msg, -1);
379 }
Structure that contains a snapshot of information about a bridge.
Definition: bridge.h:314
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct ast_bridge_snapshot * current_snapshot
Definition: bridge.h:406
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct ast_bridge_snapshot * ast_bridge_snapshot_create(struct ast_bridge *bridge)
Generate a snapshot of the bridge state. This is an ao2 object, so ao2_cleanup() to deallocate...
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
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 202 of file stasis_bridges.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_ref, AST_BRIDGE_FLAG_INVISIBLE, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, AST_LIST_TRAVERSE, ast_str_container_add(), ast_str_container_alloc, ast_string_field_init, ast_string_field_set, bridge_snapshot_dtor(), ast_bridge_technology::capabilities, ast_bridge_snapshot::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_snapshot::feature_flags, ast_bridge::feature_flags, ast_bridge_technology::name, ast_bridge_methods::name, ast_bridge::name, ast_bridge_snapshot::num_active, ast_bridge::num_active, ast_bridge_snapshot::num_channels, ast_bridge::num_channels, ast_bridge::softmix, 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(), and bridge_merge_message_create().

203 {
204  struct ast_bridge_snapshot *snapshot;
205  struct ast_bridge_channel *bridge_channel;
206 
207  if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_INVISIBLE)) {
208  return NULL;
209  }
210 
211  snapshot = ao2_alloc_options(sizeof(*snapshot), bridge_snapshot_dtor,
213  if (!snapshot) {
214  return NULL;
215  }
216 
217  if (ast_string_field_init(snapshot, 128)) {
218  ao2_ref(snapshot, -1);
219 
220  return NULL;
221  }
222 
223  snapshot->channels = ast_str_container_alloc(SNAPSHOT_CHANNELS_BUCKETS);
224  if (!snapshot->channels) {
225  ao2_ref(snapshot, -1);
226 
227  return NULL;
228  }
229 
230  AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
231  if (ast_str_container_add(snapshot->channels,
232  ast_channel_uniqueid(bridge_channel->chan))) {
233  ao2_ref(snapshot, -1);
234 
235  return NULL;
236  }
237  }
238 
239  ast_string_field_set(snapshot, uniqueid, bridge->uniqueid);
240  ast_string_field_set(snapshot, technology, bridge->technology->name);
241  ast_string_field_set(snapshot, subclass, bridge->v_table->name);
242  ast_string_field_set(snapshot, creator, bridge->creator);
243  ast_string_field_set(snapshot, name, bridge->name);
244 
245  snapshot->feature_flags = bridge->feature_flags;
246  snapshot->capabilities = bridge->technology->capabilities;
247  snapshot->num_channels = bridge->num_channels;
248  snapshot->num_active = bridge->num_active;
249  snapshot->creationtime = bridge->creationtime;
250  snapshot->video_mode = bridge->softmix.video_mode.mode;
252  && bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc) {
253  ast_string_field_set(snapshot, video_source_id,
254  ast_channel_uniqueid(bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc));
255  } else if (snapshot->video_mode == AST_BRIDGE_VIDEO_MODE_TALKER_SRC
256  && bridge->softmix.video_mode.mode_data.talker_src_data.chan_vsrc) {
257  ast_string_field_set(snapshot, video_source_id,
258  ast_channel_uniqueid(bridge->softmix.video_mode.mode_data.talker_src_data.chan_vsrc));
259  }
260 
261  return snapshot;
262 }
struct ao2_container * channels
Definition: bridge.h:331
struct timeval creationtime
Definition: bridge.h:343
struct ast_flags feature_flags
Definition: bridge.h:369
const ast_string_field uniqueid
Definition: bridge.h:401
unsigned int num_active
Definition: bridge.h:375
const char * name
Definition: bridge.h:259
Structure that contains a snapshot of information about a bridge.
Definition: bridge.h:314
struct ast_bridge_video_mode video_mode
Definition: bridge.h:279
const ast_string_field name
Definition: bridge.h:401
struct ast_channel * chan_vsrc
Definition: bridge.h:116
#define ast_str_container_alloc(buckets)
Allocates a hash container for bare strings.
Definition: strings.h:1365
struct ast_bridge_softmix softmix
Definition: bridge.h:367
static void bridge_snapshot_dtor(void *obj)
Destructor for bridge snapshots.
struct ast_bridge_technology * technology
Definition: bridge.h:355
uint32_t capabilities
Definition: bridge.h:335
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
const struct ast_bridge_methods * v_table
Definition: bridge.h:351
enum ast_bridge_video_mode_type video_mode
Definition: bridge.h:341
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct timeval creationtime
Definition: bridge.h:408
struct ast_flags feature_flags
Definition: bridge.h:333
unsigned int num_channels
Definition: bridge.h:337
unsigned int num_active
Definition: bridge.h:339
struct ast_bridge_channels_list channels
Definition: bridge.h:363
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan_vsrc
Definition: bridge.h:123
Definition: search.h:40
const ast_string_field creator
Definition: bridge.h:401
unsigned int num_channels
Definition: bridge.h:373
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
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
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 712 of file stasis_bridges.c.

References AST_BRIDGE_VIDEO_MODE_NONE, ast_bridge_video_mode_to_string(), ast_json_object_set(), ast_json_pack(), ast_json_string_create(), ast_json_timeval(), ast_bridge_snapshot::capabilities, ast_bridge_snapshot::channels, ast_bridge_snapshot::creationtime, ast_bridge_snapshot::creator, ast_bridge_snapshot::name, 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 ast_ari_bridges_create(), ast_ari_bridges_create_with_id(), ast_ari_bridges_get(), and ast_ari_bridges_list().

715 {
716  struct ast_json *json_bridge;
717  struct ast_json *json_channels;
718 
719  if (snapshot == NULL) {
720  return NULL;
721  }
722 
723  json_channels = container_to_json_array(snapshot->channels, sanitize);
724  if (!json_channels) {
725  return NULL;
726  }
727 
728  json_bridge = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: o, s: o, s: s}",
729  "id", snapshot->uniqueid,
730  "technology", snapshot->technology,
731  "bridge_type", capability2str(snapshot->capabilities),
732  "bridge_class", snapshot->subclass,
733  "creator", snapshot->creator,
734  "name", snapshot->name,
735  "channels", json_channels,
736  "creationtime", ast_json_timeval(snapshot->creationtime, NULL),
737  "video_mode", ast_bridge_video_mode_to_string(snapshot->video_mode));
738  if (!json_bridge) {
739  return NULL;
740  }
741 
742  if (snapshot->video_mode != AST_BRIDGE_VIDEO_MODE_NONE
743  && !ast_strlen_zero(snapshot->video_source_id)) {
744  ast_json_object_set(json_bridge, "video_source_id",
746  }
747 
748  return json_bridge;
749 }
struct ao2_container * channels
Definition: bridge.h:331
struct timeval creationtime
Definition: bridge.h:343
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
const ast_string_field video_source_id
Definition: bridge.h:328
const ast_string_field creator
Definition: bridge.h:328
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
uint32_t capabilities
Definition: bridge.h:335
const ast_string_field technology
Definition: bridge.h:328
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition: json.c:278
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:3951
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
Definition: json.c:670
const ast_string_field name
Definition: bridge.h:328
enum ast_bridge_video_mode_type video_mode
Definition: bridge.h:341
const ast_string_field uniqueid
Definition: bridge.h:328
Abstract JSON element (object, array, string, int, ...).
const ast_string_field subclass
Definition: bridge.h:328
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 184 of file stasis_bridges.c.

References ast_bridge_topic_all(), and ast_bridge::topic.

Referenced by ast_ari_bridges_record(), ast_bridge_publish_enter(), ast_bridge_publish_leave(), ast_bridge_publish_state(), bridge_base_init(), and forwards_create_bridge().

185 {
186  if (!bridge) {
187  return ast_bridge_topic_all();
188  }
189 
190  return bridge->topic;
191 }
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
struct stasis_topic * topic
Definition: bridge.h:359
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 179 of file stasis_bridges.c.

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

180 {
181  return bridge_topic_all;
182 }