44#define SNAPSHOT_CHANNELS_BUCKETS 1
190 return bridge->
topic;
269 update->old_snapshot ?
update->old_snapshot->uniqueid :
"<none>",
270 update->new_snapshot ?
update->new_snapshot->uniqueid :
"<none>");
289 update->old_snapshot ?
update->old_snapshot->uniqueid :
"<none>",
290 update->new_snapshot ?
update->new_snapshot->uniqueid :
"<none>");
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) {
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;
1336 for (i = 0; i < 2; ++i) {
static const char * stasis
Dialplan application name.
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ao2_iterator_next(iter)
@ AO2_ALLOC_OPT_LOCK_NOLOCK
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_alloc(data_size, destructor_fn)
#define ast_bridge_unlock(bridge)
Unlock the bridge.
@ AST_BRIDGE_CAPABILITY_HOLDING
struct ast_bridge * ast_bridge_find_by_id(const char *bridge_id)
Find bridge by id.
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.
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.
@ AST_BRIDGE_TRANSFER_NOT_PERMITTED
@ AST_BRIDGE_TRANSFER_SUCCESS
@ AST_BRIDGE_TRANSFER_INVALID
@ AST_BRIDGE_TRANSFER_FAIL
@ AST_BRIDGE_VIDEO_MODE_SINGLE_SRC
@ AST_BRIDGE_VIDEO_MODE_TALKER_SRC
@ AST_BRIDGE_VIDEO_MODE_NONE
#define ast_bridge_lock(bridge)
Lock the bridge.
@ AST_BRIDGE_FLAG_INVISIBLE
General Asterisk PBX channel definitions.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
static struct ao2_container * locals
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,...
#define ast_debug(level,...)
Log a DEBUG message.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
struct ast_json * ast_json_boolean(int value)
Get the JSON boolean corresponding to value.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
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_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
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.
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.
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_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.
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
void stasis_topic_pool_delete_topic(struct stasis_topic_pool *pool, const char *topic_name)
Delete a topic from the topic pool.
const char * stasis_topic_name(const struct stasis_topic *topic)
Return the name of a topic.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
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.
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
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.
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.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
const struct timeval * stasis_message_timestamp(const struct stasis_message *msg)
Get the time when a message was created.
void ast_bridge_publish_merge(struct ast_bridge *to, struct ast_bridge *from)
Publish a bridge merge.
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *uniqueid)
Returns the current snapshot for the bridge.
static const char * capability2str(uint32_t capabilities)
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.
void ast_bridge_publish_blind_transfer(struct ast_blind_transfer_message *transfer_message)
Publish a blind transfer event.
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 struct stasis_topic_pool * bridge_topic_pool
static void stasis_bridging_cleanup(void)
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_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.
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.
static struct ast_json * attended_transfer_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.
struct ast_bridge_snapshot * ast_bridge_get_snapshot(struct ast_bridge *bridge)
Returns the current snapshot for the bridge.
#define SNAPSHOT_CHANNELS_BUCKETS
static void blind_transfer_dtor(void *obj)
int bridge_topics_init(struct ast_bridge *bridge)
void ast_bridge_publish_leave(struct ast_bridge *bridge, struct ast_channel *chan)
Publish a bridge channel leave event.
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.
static struct ast_bridge_merge_message * bridge_merge_message_create(struct ast_bridge *to, struct ast_bridge *from)
Bridge merge message creation helper.
static struct ast_json * blind_transfer_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
static void attended_transfer_dtor(void *obj)
static struct ast_manager_event_blob * blind_transfer_to_ami(struct stasis_message *message)
static struct ast_manager_event_blob * attended_transfer_to_ami(struct stasis_message *message)
static struct stasis_topic * bridge_topic_all
static struct ast_bridge_snapshot_update * bridge_snapshot_update_create(struct ast_bridge_snapshot *old, struct ast_bridge_snapshot *new)
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)
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 int bridge_channel_snapshot_pair_init(struct ast_channel *channel, struct ast_bridge *bridge, struct ast_bridge_channel_snapshot_pair *snapshot_pair)
static void bridge_channel_snapshot_pair_cleanup(struct ast_bridge_channel_snapshot_pair *pair)
void ast_bridge_publish_state(struct ast_bridge *bridge)
Publish the state of a 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.
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.
static void bridge_snapshot_dtor(void *obj)
Destructor for bridge snapshots.
static void bridge_merge_message_dtor(void *obj)
Destructor for bridge merge messages.
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 const char * result_strs[]
static struct ast_json * ast_channel_entered_bridge_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
static struct ast_json * container_to_json_array(struct ao2_container *items, const struct stasis_message_sanitizer *sanitize)
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.
STASIS_MESSAGE_TYPE_DEFN(ast_bridge_snapshot_type)
Define bridge message types.
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
static void bridge_snapshot_update_dtor(void *obj)
int ast_stasis_bridging_init(void)
void bridge_topics_destroy(struct ast_bridge *bridge)
void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
Publish a bridge channel enter event.
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 stasis_message_type * ast_bridge_snapshot_type(void)
Message type for ast_bridge_snapshot.
struct stasis_message_type * ast_channel_entered_bridge_type(void)
Message type for ast_channel enter bridge blob messages.
struct stasis_message_type * ast_blind_transfer_type(void)
Message type for ast_blind_transfer_message.
struct stasis_message_type * ast_attended_transfer_type(void)
Message type for ast_attended_transfer_message.
struct stasis_message_type * ast_bridge_merge_message_type(void)
Message type for ast_bridge_merge_message.
@ 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
struct stasis_message_type * ast_channel_left_bridge_type(void)
Message type for ast_channel leave bridge blob messages.
Caching pattern for Stasis Message Bus API topics.
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.
#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_string_field_free_memory(x)
free all memory - to be called before destroying the object
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_container_alloc(buckets)
Allocates a hash container for bare strings.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
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.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Message representing attended transfer.
union ast_attended_transfer_message::@284 dest
enum ast_attended_transfer_dest_type dest_type
struct ast_channel_snapshot * replace_channel
struct ast_channel_snapshot * links[2]
struct ast_bridge_channel_snapshot_pair to_transfer_target
struct ast_channel_snapshot * transferee
struct ast_bridge_channel_snapshot_pair threeway
enum ast_transfer_result result
struct ast_bridge_channel_snapshot_pair to_transferee
char bridge[AST_UUID_STR_LEN]
struct ast_channel_snapshot * target
Message published during a blind transfer.
struct ast_channel_snapshot * replace_channel
char exten[AST_MAX_EXTENSION]
struct ast_bridge_snapshot * bridge
struct ast_channel_snapshot * transferer
struct ast_channel_snapshot * transferee
enum ast_transfer_result result
char context[AST_MAX_CONTEXT]
Blob of data associated with a bridge.
struct ast_bridge_snapshot * bridge
struct ast_channel_snapshot * channel
Pair showing a bridge snapshot and a specific channel snapshot belonging to the bridge.
struct ast_bridge_snapshot * bridge_snapshot
struct ast_channel_snapshot * channel_snapshot
Structure that contains information regarding a channel in a bridge.
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_channel * chan
Message representing the merge of two bridges.
struct ast_bridge_snapshot * from
struct ast_bridge_snapshot * to
Structure that contains a snapshot of information about a bridge.
enum ast_bridge_video_mode_type video_mode
struct timeval creationtime
const ast_string_field video_source_id
const ast_string_field creator
const ast_string_field uniqueid
unsigned int num_channels
const ast_string_field technology
const ast_string_field name
struct ao2_container * channels
const ast_string_field subclass
struct ast_flags feature_flags
struct ast_bridge_video_mode video_mode
struct ast_bridge_video_single_src_data single_src_data
struct ast_bridge_video_talker_src_data talker_src_data
union ast_bridge_video_mode::@189 mode_data
enum ast_bridge_video_mode_type mode
struct ast_channel * chan_vsrc
struct ast_channel * chan_vsrc
Structure that contains information about a bridge.
struct stasis_topic * topic
struct ast_bridge_softmix softmix
struct timeval creationtime
const struct ast_bridge_methods * v_table
const ast_string_field creator
const ast_string_field uniqueid
struct ast_bridge_channels_list channels
struct ast_bridge_snapshot * current_snapshot
unsigned int num_channels
struct ast_bridge_technology * technology
const ast_string_field name
struct ast_flags feature_flags
const ast_string_field uniqueid
const ast_string_field name
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_base * base
Main Channel structure associated with a channel.
Abstract JSON element (object, array, string, int, ...).
Struct containing info for an AMI event to send out.
Support for dynamic strings.
Structure containing callbacks for Stasis message sanitization.
int(* channel_id)(const char *channel_id)
Callback which determines whether a channel should be sanitized from a message based on the channel's...
static struct aco_type item
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.