Asterisk - The Open Source Telephony Project
21.4.1
|
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_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. More... | |
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. More... | |
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. More... | |
struct stasis_message * | ast_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_snapshot * | ast_bridge_get_snapshot (struct ast_bridge *bridge) |
Returns the current snapshot for the bridge. More... | |
struct ast_bridge_snapshot * | ast_bridge_get_snapshot_by_uniqueid (const char *uniqueid) |
Returns the current snapshot for the bridge. More... | |
static struct ast_json * | ast_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_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. More... | |
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. More... | |
struct stasis_topic * | ast_bridge_topic (struct ast_bridge *bridge) |
A topic which publishes the events for a particular bridge. More... | |
struct stasis_topic * | ast_bridge_topic_all (void) |
A topic which publishes the events for all bridges. More... | |
static struct ast_json * | ast_channel_entered_bridge_to_json (struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize) |
static struct ast_json * | ast_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_blob * | attended_transfer_to_ami (struct stasis_message *message) |
static struct ast_json * | attended_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_blob * | blind_transfer_to_ami (struct stasis_message *message) |
static struct ast_json * | blind_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_message * | bridge_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_update * | bridge_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_json * | container_to_json_array (struct ao2_container *items, const struct stasis_message_sanitizer *sanitize) |
static struct ast_json * | simple_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_topic * | bridge_topic_all |
static struct stasis_topic_pool * | bridge_topic_pool |
static const char * | result_strs [] |
Stasis Messages and Data Types for Bridge Objects.
Definition in file stasis_bridges.c.
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.
transfer_msg | The message to add details to |
app | The name of the application that the parties are being transferred to |
replace_channel | The local channel that is in the bridge and running the application |
0 | Success |
-1 | Failure |
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().
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.
transfer_msg | The message to add details to. |
locals | An array of local channel halves that each are in one of the involved bridges. |
0 | Success |
-1 | Failure |
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().
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.
transfer_msg | The transfer message to add details to |
final_bridge | The bridge where the surviving parties reside |
0 | Success |
-1 | Failure |
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().
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.
transfer_msg | The message to add details to |
survivor_channel | The transferer channel that exists in the three-way call |
survivor_bridge | The bridge where the three-way call takes place. |
0 | Success |
-1 | Failure |
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().
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.
is_external | Non-zero if the transfer was initiated by a native channel driver protocol. |
to_transferee | The transferer channel that is bridged to the transferee channel. |
transferee_bridge | The bridge between the transferer and transferee. May be NULL. |
to_transfer_target | The transferer channel that is bridged to the transfer target. |
target_bridge | The bridge between the transferer and transfer target. May be NULL. |
transferee | The channel that is being transferred. Optional. |
transfer_target | The channel that is being transferred to. Optional. |
NULL | Failure to allocate or create snapshots |
non-NULL | The 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().
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.
is_external | Whether the blind transfer was initiated externally (e.g. via AMI or native protocol) |
transferer | The transferer's channel that is bridged to the transferee |
exten | The destination extension for the blind transfer |
context | The destination context for the blind transfer |
NULL | Failure to allocate or create snapshots |
non-NULL | The 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().
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.
"type"
field describing the blob. It should also be treated as immutable and not modified after it is put into the message.type | |
bridge | Channel blob is associated with, or NULL for global/all bridges. |
chan | The channel that started the bridge |
blob | JSON object representing the data. |
NULL | on 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().
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.
"type"
field describing the blob. It should also be treated as immutable and not modified after it is put into the message.type | |
bridge_snapshot | Bridge snapshot |
chan_snapshot | Channel snapshot |
blob | JSON object representing the data. |
NULL | on 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().
struct ast_bridge_snapshot* ast_bridge_get_snapshot | ( | struct ast_bridge * | bridge | ) |
Returns the current snapshot for the bridge.
The returned pointer is AO2 managed, so ao2_cleanup() when you're done.
bridge | The bridge from which to get the snapshot. |
NULL | if 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().
struct ast_bridge_snapshot* ast_bridge_get_snapshot_by_uniqueid | ( | const char * | bridge_id | ) |
Returns the current snapshot for the bridge.
The returned pointer is AO2 managed, so ao2_cleanup() when you're done.
bridge_id | Uniqueid of the bridge from which to get the snapshot. |
NULL | if 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().
void ast_bridge_publish_attended_transfer | ( | struct ast_attended_transfer_message * | transfer_msg | ) |
Publish an attended transfer.
transfer_msg | The 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().
void ast_bridge_publish_blind_transfer | ( | struct ast_blind_transfer_message * | transfer_message | ) |
Publish a blind transfer event.
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().
void ast_bridge_publish_enter | ( | struct ast_bridge * | bridge, |
struct ast_channel * | chan, | ||
struct ast_channel * | swap | ||
) |
Publish a bridge channel enter event.
bridge | The bridge a channel entered |
chan | The channel that entered the bridge |
swap | The 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().
void ast_bridge_publish_leave | ( | struct ast_bridge * | bridge, |
struct ast_channel * | chan | ||
) |
Publish a bridge channel leave event.
bridge | The bridge a channel left |
chan | The 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().
void ast_bridge_publish_merge | ( | struct ast_bridge * | to, |
struct ast_bridge * | from | ||
) |
Publish a bridge merge.
to | The bridge to which channels are being added |
from | The 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().
void ast_bridge_publish_state | ( | struct ast_bridge * | bridge | ) |
Publish the state of a bridge.
bridge | The 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().
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.
bridge | The bridge from which to generate a snapshot |
NULL | on 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().
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.
snapshot | The bridge snapshot to convert to JSON |
sanitize | The message sanitizer to use on the snapshot |
NULL | on 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().
struct stasis_topic* ast_bridge_topic | ( | struct ast_bridge * | bridge | ) |
A topic which publishes the events for a particular bridge.
NULL
, ast_bridge_topic_all() is returned.bridge | Bridge for which to get a topic or NULL . |
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().
struct stasis_topic* ast_bridge_topic_all | ( | void | ) |
A topic which publishes the events for all bridges.
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().