44 #define SNAPSHOT_CHANNELS_BUCKETS 1 190 return bridge->
topic;
268 ast_debug(3,
"Update: %p Old: %s New: %s\n", update,
288 ast_debug(3,
"Update: %p Old: %s New: %s\n", update,
312 if (!bridge->
topic) {
429 if (!msg->
to || !msg->
from) {
446 if (!json_bridge_to || !json_bridge_from) {
454 "type",
"BridgeMerged",
456 "bridge", json_bridge_to,
457 "bridge_from", json_bridge_from);
493 event->bridge =
NULL;
495 event->channel =
NULL;
564 if (bridge_snapshot) {
633 const struct timeval *tv,
639 if (!json_bridge || !json_channel) {
649 "bridge", json_bridge,
650 "channel", json_channel);
719 if (snapshot ==
NULL) {
724 if (!json_channels) {
728 json_bridge =
ast_json_pack(
"{s: s, s: s, s: s, s: s, s: s, s: s, s: o, s: o, s: s}",
734 "name", snapshot->
name,
735 "channels", json_channels,
810 if (!json_transferer) {
816 if (!json_transferee) {
831 out =
ast_json_pack(
"{s: s, s: o, s: o, s: s, s: s, s: s, s: o}",
832 "type",
"BridgeBlindTransfer",
834 "channel", json_transferer,
835 "exten", transfer_msg->
exten,
836 "context", transfer_msg->
context,
857 if (transfer_msg->
bridge) {
859 transfer_msg->
bridge, sanitize);
883 if (!transferer_state) {
887 if (transfer_msg->
bridge) {
897 if (!transferee_state) {
916 transfer_msg->
exten);
972 struct ast_json *json_transferer1, *json_transferer2, *json_bridge, *json_channel;
978 if (!json_transferer1) {
983 if (!json_transferer2) {
990 if (!json_transferee) {
997 if (transfer_msg->
target) {
1008 "type",
"BridgeAttendedTransfer",
1010 "transferer_first_leg", json_transferer1,
1011 "transferer_second_leg", json_transferer2,
1063 if (!json_channel) {
1069 if (!json_channel) {
1079 if (!json_channel) {
1116 if (!variable_data) {
1122 if (!transferer1_state || !transferer2_state) {
1127 if (!transferee_state) {
1132 if (transfer_msg->
target) {
1134 if (!target_state) {
1142 if (!bridge1_state) {
1150 if (!bridge2_state) {
1168 if (!local1_state || !local2_state) {
1193 "IsExternal: %s\r\n" 1234 if (!transfer_msg) {
1250 }
else if (transferee_bridge) {
1262 if (transfer_target) {
1264 if (!transfer_msg->
target) {
1268 }
else if (target_bridge) {
1270 if (transfer_target) {
1273 if (!transfer_msg->
target) {
1280 return transfer_msg;
1318 if (replace_channel) {
1336 for (i = 0; i < 2; ++i) {
1402 bridge_topic_pool =
NULL;
1404 bridge_topic_all =
NULL;
1414 if (!bridge_topic_all) {
1418 if (!bridge_topic_pool) {
struct stasis_message_type * ast_bridge_snapshot_type(void)
Message type for ast_bridge_snapshot.
struct stasis_message_type * ast_blind_transfer_type(void)
Message type for ast_blind_transfer_message.
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.
Struct containing info for an AMI event to send out.
struct ao2_container * channels
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
Caching pattern for Stasis Message Bus API topics.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
struct timeval creationtime
struct ast_channel_snapshot_base * base
union ast_attended_transfer_message::@324 dest
static void bridge_snapshot_update_dtor(void *obj)
Asterisk main include file. File version handling, generic pbx functions.
struct ast_flags feature_flags
int bridge_topics_init(struct ast_bridge *bridge)
const ast_string_field uniqueid
#define SNAPSHOT_CHANNELS_BUCKETS
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
static struct ast_manager_event_blob * attended_transfer_to_ami(struct stasis_message *message)
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_channel_entered_bridge_type(void)
Message type for channel enter bridge blob messages.
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.
Message representing attended transfer.
struct ast_channel_snapshot * channel
struct ast_bridge * ast_bridge_find_by_id(const char *bridge_id)
Find bridge by id.
#define ast_test_flag(p, flag)
char exten[AST_MAX_EXTENSION]
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Message published during a blind transfer.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *uniqueid)
Returns the current snapshot for the bridge.
void ast_bridge_publish_leave(struct ast_bridge *bridge, struct ast_channel *chan)
Publish a bridge channel leave event.
void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
Publish a bridge channel enter event.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
int(* channel_id)(const char *channel_id)
Callback which determines whether a channel should be sanitized from a message based on the channel's...
struct stasis_message_type * ast_channel_left_bridge_type(void)
Message type for channel leave bridge blob messages.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
void ast_bridge_publish_attended_transfer(struct ast_attended_transfer_message *transfer_msg)
Publish an attended transfer.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Structure that contains a snapshot of information about a bridge.
struct ast_bridge_video_mode video_mode
void ast_bridge_publish_blind_transfer(struct ast_blind_transfer_message *transfer_message)
Publish a blind transfer event.
const ast_string_field name
const ast_string_field video_source_id
Structure representing a snapshot of channel state.
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.
struct ast_channel * chan_vsrc
#define ast_str_container_alloc(buckets)
Allocates a hash container for bare strings.
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct ast_channel_snapshot * target
const ast_string_field uniqueid
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static struct aco_type item
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_alloc_options(data_size, destructor_fn, options)
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.
char bridge[AST_UUID_STR_LEN]
void ast_free_ptr(void *ptr)
free() wrapper
static int bridge_channel_snapshot_pair_init(struct ast_channel *channel, struct ast_bridge *bridge, struct ast_bridge_channel_snapshot_pair *snapshot_pair)
struct ast_bridge_softmix softmix
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.
union ast_bridge_video_mode::@227 mode_data
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.
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
const ast_string_field creator
Structure containing callbacks for Stasis message sanitization.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
struct ast_str * ast_manager_build_bridge_state_string_prefix(const struct ast_bridge_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a bridge snapshot.
#define ast_strlen_zero(foo)
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...
static void bridge_snapshot_dtor(void *obj)
Destructor for bridge snapshots.
struct ast_bridge_technology * technology
struct ast_bridge_channel_snapshot_pair to_transfer_target
struct ast_bridge_snapshot * bridge
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.
#define ast_debug(level,...)
Log a DEBUG message.
static void blind_transfer_dtor(void *obj)
enum ast_transfer_result result
struct stasis_message_type * ast_bridge_merge_message_type(void)
Message type for ast_bridge_merge_message.
const ast_string_field technology
General Asterisk PBX channel definitions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
void bridge_topics_destroy(struct ast_bridge *bridge)
void ast_bridge_publish_merge(struct ast_bridge *to, struct ast_bridge *from)
Publish a bridge merge.
struct ast_channel_snapshot * links[2]
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
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.
static void attended_transfer_dtor(void *obj)
struct ast_channel_snapshot * transferee
const struct timeval * stasis_message_timestamp(const struct stasis_message *msg)
Get the time when a message was created.
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 struct ast_manager_event_blob * blind_transfer_to_ami(struct stasis_message *message)
struct ast_bridge_video_talker_src_data talker_src_data
#define ao2_ref(o, delta)
static struct ast_bridge_snapshot_update * bridge_snapshot_update_create(struct ast_bridge_snapshot *old, struct ast_bridge_snapshot *new)
struct ast_channel_snapshot * replace_channel
static struct ast_json * ast_bridge_merge_message_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
struct ast_bridge_snapshot * bridge
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
struct ast_bridge_video_single_src_data single_src_data
struct ast_str * ast_manager_build_bridge_state_string(const struct ast_bridge_snapshot *snapshot)
Generate the AMI message body from a bridge snapshot.
struct ast_bridge_snapshot * old_snapshot
Blob of data associated with a bridge.
static void bridge_merge_message_dtor(void *obj)
Destructor for bridge merge messages.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
enum ast_attended_transfer_dest_type dest_type
int ast_stasis_bridging_init(void)
const struct ast_bridge_methods * v_table
struct ast_bridge_snapshot * ast_bridge_get_snapshot(struct ast_bridge *bridge)
Returns the current snapshot for the bridge.
void stasis_topic_pool_delete_topic(struct stasis_topic_pool *pool, const char *topic_name)
Delete a topic from the topic pool.
struct ast_bridge_snapshot * current_snapshot
Structure that contains information about a bridge.
struct ast_channel_snapshot * transferer
struct ast_channel_snapshot * channel_snapshot
static void bridge_channel_snapshot_pair_cleanup(struct ast_bridge_channel_snapshot_pair *pair)
static struct stasis_topic_pool * bridge_topic_pool
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
const ast_string_field name
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
enum ast_bridge_video_mode_type video_mode
static struct stasis_topic * bridge_topic_all
const char * stasis_topic_name(const struct stasis_topic *topic)
Return the name of a topic.
char context[AST_MAX_CONTEXT]
static struct ast_json * blind_transfer_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
#define ao2_iterator_next(iter)
#define ao2_alloc(data_size, destructor_fn)
struct ast_bridge_channel_snapshot_pair threeway
struct stasis_message_type * ast_attended_transfer_type(void)
Message type for ast_attended_transfer_message.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
struct ast_bridge_snapshot * bridge_snapshot
struct ast_json * ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_channel_snapshot.
struct timeval creationtime
#define ast_bridge_unlock(bridge)
Unlock the bridge.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
static struct ast_json * container_to_json_array(struct ao2_container *items, const struct stasis_message_sanitizer *sanitize)
static const char * stasis
Dialplan application name.
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 to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
static struct ast_json * ast_channel_left_bridge_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
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.
static void bridge_publish_state_from_blob(struct ast_bridge *bridge, struct ast_bridge_blob *obj)
const ast_string_field uniqueid
struct ast_bridge_snapshot * new_snapshot
static void bridge_blob_dtor(void *obj)
struct ast_flags feature_flags
unsigned int num_channels
struct ast_bridge_snapshot * from
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
#define ast_bridge_lock(bridge)
Lock the bridge.
struct ast_bridge_channels_list channels
Message representing the merge of two bridges.
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
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...
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
struct ast_channel * chan_vsrc
static const char * result_strs[]
static void stasis_bridging_cleanup(void)
struct stasis_topic * topic
Abstract JSON element (object, array, string, int, ...).
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.
struct ast_json * ast_json_boolean(int value)
Get the JSON boolean corresponding to value.
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.
static char context[AST_MAX_CONTEXT]
struct ast_channel_snapshot * transferee
static struct ao2_container * locals
const ast_string_field creator
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.
const ast_string_field subclass
STASIS_MESSAGE_TYPE_DEFN(ast_bridge_snapshot_type)
Define bridge message types.
static struct ast_json * attended_transfer_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
enum ast_transfer_result result
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
unsigned int num_channels
enum ast_bridge_video_mode_type mode
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.
static const char * capability2str(uint32_t capabilities)
const ast_string_field name
struct ast_channel_snapshot * replace_channel
struct ast_bridge_snapshot * to
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
void ast_bridge_publish_state(struct ast_bridge *bridge)
Publish the state of a bridge.
Pair showing a bridge snapshot and a specific channel snapshot belonging to the bridge.
static struct ast_json * ast_channel_entered_bridge_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)