77#define MAX_WAIT_MS 200
83#define APPS_NUM_BUCKETS 127
89#define CONTROLS_NUM_BUCKETS 127
95#define BRIDGES_NUM_BUCKETS 127
159 "type",
"StasisStart",
186static int app_hash(
const void *obj,
const int flags)
212 const char *right_key = arg;
227 cmp = strncmp(
stasis_app_name(object_left), right_key, strlen(right_key));
274 const char *right_key = arg;
350 const char *channel_id)
382 const char *right_key = arg;
390 cmp = strcmp(object_left->
uniqueid, right_key);
397 cmp = strncmp(object_left->
uniqueid, right_key, strlen(right_key));
433 const char *right_key = arg;
440 cmp = strcmp(object_left->
bridge_id, right_key);
443 cmp = strncmp(object_left->
bridge_id, right_key, strlen(right_key));
487 const char *right_key = obj_right;
495 cmp = strcmp(left->
bridge_id, right_key);
498 cmp = strncmp(left->
bridge_id, right_key, strlen(right_key));
619 ast_log(
LOG_ERROR,
"Failed to create channel thread. Abandoning MOH channel creation.\n");
693 char *bridge_id = data;
700 char *bridge_id = data;
765 if (!playback_wrapper) {
775 const char *bridge_id)
799 int capabilities = 0;
804 int send_sdp_label = 0;
810 while ((requested_type =
strsep(&requested_types,
","))) {
811 requested_type =
ast_strip(requested_type);
813 if (!strcmp(requested_type,
"mixing")) {
816 }
else if (!strcmp(requested_type,
"holding")) {
818 }
else if (!strcmp(requested_type,
"dtmf_events") ||
819 !strcmp(requested_type,
"proxy_media")) {
820 capabilities &= ~AST_BRIDGE_CAPABILITY_NATIVE;
821 }
else if (!strcmp(requested_type,
"video_sfu")) {
823 }
else if (!strcmp(requested_type,
"video_single")) {
825 }
else if (!strcmp(requested_type,
"sdp_label")) {
833 flags &= ~AST_BRIDGE_FLAG_SMART;
889 .
type =
"replace-channel-store",
900 if (!datastore && !no_create) {
912 if (!datastore->
data) {
916 ret = datastore->
data;
964 replace_channel_snapshot =
replace->snapshot;
967 return replace_channel_snapshot;
973 char *replace_channel_app;
979 replace_channel_app =
replace->app;
982 return replace_channel_app;
1028 payload->
blob = json_blob;
1034 for (i = 0; i < argc; ++i) {
1052 if (replace_channel_snapshot) {
1061 int argc,
char *argv[])
1092 if (sanitize && sanitize->
channel
1175 if (!new_snapshot) {
1182 if (!old_snapshot) {
1209 .
type =
"stasis-masquerade",
1287 .
type =
"stasis_end_published",
1310 return datastore ? 1 : 0;
1350 "Stasis app '%s' not registered\n",
app_name);
1355 "Stasis app '%s' not active\n",
app_name);
1384 "Error sending start message to '%s'\n",
app_name);
1458 for (idx = 0; idx < next_argc; idx++) {
1498 "type",
"ApplicationMoveFailed",
1504 ast_log(
LOG_ERROR,
"Failed to pack JSON for ApplicationMoveFailed message\n");
1512 for (idx = 0; idx < next_argc; ++idx) {
1532 last_bridge = bridge;
1535 if (bridge != last_bridge) {
1575 ast_debug(3,
"%s: Hangup (no more frames)\n",
1649 memset(&pbx_args, 0,
sizeof(pbx_args));
1673 "Stasis app '%s' not registered\n",
app_name);
1805 "Stasis app '%s' not registered\n",
app_name);
1832 if (source == obj) {
1943 const char *
app_name,
const char **event_source_uris,
1944 int event_sources_count,
struct ast_json **json,
1956 for (i = 0; i < event_sources_count; ++i) {
1957 const char *uri = event_source_uris[i];
1962 if (!event_source) {
2032 (!event_source->
find || (!(obj = event_source->
find(
app, uri + strlen(event_source->
scheme)))))) {
2049 const char **event_source_uris,
int event_sources_count,
2053 app_name, event_source_uris, event_sources_count,
2072 const char *
id = uri + strlen(event_source->
scheme);
2090 const char **event_source_uris,
int event_sources_count,
2094 app_name, event_source_uris, event_sources_count,
2099 const char *event_name,
2100 const char **source_uris,
int sources_count,
2108 int have_channel = 0;
2120 if (json_variables) {
2144 for (i = 0; i < sources_count; ++i) {
2145 const char *uri = source_uris[i];
2146 void *snapshot=
NULL;
2273 .
type =
"stasis-internal-channel",
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_unlink_flags(container, obj, flags)
Remove an object from a container.
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
#define ao2_find(container, arg, flags)
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
#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.
@ OBJ_SEARCH_PARTIAL_KEY
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
@ OBJ_SEARCH_OBJECT
The arg parameter is an object of the same type.
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
@ OBJ_SEARCH_MASK
Search option field mask.
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT
Reject objects with duplicate keys in container.
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
@ AST_BRIDGE_CAPABILITY_MULTIMIX
@ AST_BRIDGE_CAPABILITY_HOLDING
ast_bridge_video_mode_type
Video source modes.
@ AST_BRIDGE_VIDEO_MODE_SINGLE_SRC
@ AST_BRIDGE_VIDEO_MODE_TALKER_SRC
@ AST_BRIDGE_VIDEO_MODE_SFU
After Bridge Execution API.
ast_bridge_after_cb_reason
int ast_bridge_set_after_callback(struct ast_channel *chan, ast_bridge_after_cb callback, ast_bridge_after_cb_failed failed, void *data)
Setup an after bridge callback for when the channel leaves the bridging system.
@ AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY
@ AST_BRIDGE_FLAG_SWAP_INHIBIT_TO
@ AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM
@ AST_BRIDGE_FLAG_MERGE_INHIBIT_TO
@ AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM
@ AST_BRIDGE_FLAG_INVISIBLE
@ AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE
@ AST_BRIDGE_CHANNEL_FLAG_LONELY
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
Internal Asterisk hangup causes.
#define AST_CAUSE_NORMAL_CLEARING
const char * ast_channel_name(const struct ast_channel *chan)
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
int ast_channel_fdno(const struct ast_channel *chan)
#define ast_channel_lock(chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
#define ast_channel_unref(c)
Decrease channel reference count.
@ AST_SOFTHANGUP_ASYNCGOTO
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
#define ast_channel_unlock(chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
struct stasis_app_control * control_create(struct ast_channel *channel, struct stasis_app *app)
Create a control object.
int control_prestart_dispatch_all(struct stasis_app_control *control, struct ast_channel *chan)
Dispatch all queued prestart commands.
void control_wait(struct stasis_app_control *control)
Blocks until control's command queue has a command available.
char ** control_next_app_args(struct stasis_app_control *control)
Returns the list of arguments to pass to the application we are moving to.
int control_is_done(struct stasis_app_control *control)
Returns true if control_continue() has been called on this control.
void control_flush_queue(struct stasis_app_control *control)
Flush the control command queue.
int control_dispatch_all(struct stasis_app_control *control, struct ast_channel *chan)
Dispatch all commands enqueued to this control.
int control_next_app_args_size(struct stasis_app_control *control)
Returns the number of arguments to be passed to the application we are moving to.
void control_set_app(struct stasis_app_control *control, struct stasis_app *app)
Set the application the control object belongs to.
int control_command_count(struct stasis_app_control *control)
Returns the count of items in a control's command queue.
void control_silence_stop_now(struct stasis_app_control *control)
Stop playing silence to a channel right now.
char * control_next_app(struct stasis_app_control *control)
Returns the name of the application we are moving to.
struct stasis_app * control_app(struct stasis_app_control *control)
Returns the pointer (non-reffed) to the app associated with this control.
void control_move_cleanup(struct stasis_app_control *control)
Free any memory that was allocated for switching applications via /channels/{channelId}/move.
void control_mark_done(struct stasis_app_control *control)
Internal API for the Stasis application controller.
Unreal channel derivative framework.
int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge *bridge, unsigned int flags)
Push the semi2 unreal channel into a bridge from either member of the unreal pair.
void ast_unreal_lock_all(struct ast_unreal_pvt *p, struct ast_channel **outchan, struct ast_channel **outowner)
Send an unreal pvt in with no locks held and get all locks.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
void ast_multi_object_blob_add(struct ast_multi_object_blob *multi, enum stasis_user_multi_object_snapshot_type type, void *object)
Add an object to a multi object blob previously created.
stasis_user_multi_object_snapshot_type
Object type code for multi user object snapshots.
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_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate.
struct ast_multi_object_blob * ast_multi_object_blob_create(struct ast_json *blob)
Create a stasis multi object blob.
struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot(const char *tech, const char *resource)
Retrieve the most recent snapshot for the endpoint with the given name.
struct stasis_message_type * ast_multi_user_event_type(void)
Message type for custom user defined events with multi object blobs.
struct stasis_message * ast_channel_blob_create(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Creates a ast_channel_blob message.
char * strsep(char **str, const char *delims)
void ast_frame_dtor(struct ast_frame *frame)
NULL-safe wrapper for ast_frfree, good for RAII_VAR.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
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_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.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
int messaging_init(void)
Initialize the messaging layer.
int messaging_cleanup(void)
Tidy up the messaging layer.
Stasis out-of-call text message support.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
const char * app_name(struct ast_app *app)
int app_subscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Add a bridge subscription to an existing channel subscription.
void app_update(struct stasis_app *app, stasis_app_cb handler, void *data)
Update the handler and data for a res_stasis application.
int app_unsubscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Cancel the bridge subscription for an application.
void app_shutdown(struct stasis_app *app)
Tears down an application.
int app_unsubscribe_channel(struct stasis_app *app, struct ast_channel *chan)
Cancel the subscription an app has for a channel.
int app_subscribe_channel(struct stasis_app *app, struct ast_channel *chan)
Subscribes an application to a channel.
int app_is_finished(struct stasis_app *app)
Checks whether a deactivated app has no channels.
struct stasis_app * app_create(const char *name, stasis_app_cb handler, void *data, enum stasis_app_subscription_model subscription_model)
Create a res_stasis application.
int app_is_active(struct stasis_app *app)
Checks whether an app is active.
struct ast_json * app_to_json(const struct stasis_app *app)
Create a JSON representation of a stasis_app.
int app_unsubscribe_channel_id(struct stasis_app *app, const char *channel_id)
Cancel the subscription an app has for a channel.
void app_deactivate(struct stasis_app *app)
Deactivates an application.
void app_send(struct stasis_app *app, struct ast_json *message)
Send a message to an application.
Internal API for the Stasis application controller.
@ STASIS_APP_SUBSCRIBE_MANUAL
An application must manually subscribe to each resource that it cares about. This is the default appr...
@ STASIS_APP_SUBSCRIBE_ALL
An application is automatically subscribed to all resources in Asterisk, even if it does not control ...
void stasis_app_bridge_playback_channel_remove(char *bridge_id, struct stasis_app_control *control)
remove channel from list of ARI playback channels for bridges.
struct ast_json * stasis_app_object_to_json(struct stasis_app *app)
Return the JSON representation of a Stasis application.
static int send_start_msg(struct stasis_app *app, struct ast_channel *chan, int argc, char *argv[])
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
static void stasis_app_bridge_channel_wrapper_destructor(void *obj)
int app_set_replace_channel_app(struct ast_channel *chan, const char *replace_app)
Set the app that the replacement channel will be controlled by.
static struct ast_channel_snapshot * get_replace_channel_snapshot(struct ast_channel *chan)
struct ao2_container * app_bridges_playback
static void channel_replaced_cb(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
STASIS_MESSAGE_TYPE_DEFN_LOCAL(end_message_type,.to_json=stasis_end_to_json)
static struct stasis_app * find_app_by_name(const char *app_name)
#define BRIDGES_NUM_BUCKETS
Number of buckets for the Stasis bridges hash table. Remember to keep it a prime number!
int app_set_replace_channel_snapshot(struct ast_channel *chan, struct ast_channel_snapshot *replace_snapshot)
Set the snapshot of the channel that this channel will replace.
struct ast_bridge * stasis_app_bridge_create_invisible(const char *type, const char *name, const char *id)
Create an invisible bridge of the specified type.
int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc, char *argv[])
Stasis dialplan application callback.
int stasis_app_channel_is_internal(struct ast_channel *chan)
Is this channel internal to Stasis?
static void channel_stolen_cb(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
static struct ast_channel * bridge_moh_create(struct ast_bridge *bridge)
int stasis_app_send(const char *app_name, struct ast_json *message)
Send a message to the given Stasis application.
static const struct ast_datastore_info replace_channel_store_info
static int bridges_compare(void *obj, void *arg, int flags)
static void start_message_blob_dtor(void *obj)
enum stasis_app_subscribe_res stasis_app_subscribe(const char *app_name, const char **event_source_uris, int event_sources_count, struct ast_json **json)
Subscribes an application to a list of event sources.
static void playback_after_bridge_cb(struct ast_channel *chan, void *data)
void stasis_app_channel_set_stasis_end_published(struct ast_channel *chan)
Indicate that this channel has had a StasisEnd published for it.
void stasis_app_bridge_destroy(const char *bridge_id)
Destroy the bridge.
static int channel_sanitizer(const struct ast_channel *chan)
Sanitization callback for channels.
struct ao2_container * app_controls
static void playback_after_bridge_cb_failed(enum ast_bridge_after_cb_reason reason, void *data)
struct ast_json * stasis_app_to_json(const char *app_name)
Return the JSON representation of a Stasis application.
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data)
Register a new Stasis application.
static enum stasis_app_subscribe_res app_unsubscribe(struct stasis_app *app, const char *uri, struct stasis_app_event_source *event_source)
static void replace_channel_destroy(void *obj)
static void remove_stasis_end_published(struct ast_channel *chan)
static void cleanup(void)
Clean up any old apps that we don't need any more.
static int channel_snapshot_sanitizer(const struct ast_channel_snapshot *snapshot)
Sanitization callback for channel snapshots.
struct ao2_container * app_bridges_moh
int stasis_app_channel_set_internal(struct ast_channel *chan)
Mark this channel as being internal to Stasis.
static int app_compare(void *obj, void *arg, int flags)
struct ast_bridge * stasis_app_bridge_find_by_id(const char *bridge_id)
Returns the bridge with the given id.
struct ast_bridge * stasis_app_bridge_create(const char *type, const char *name, const char *id)
Create a bridge of the specified type.
void stasis_app_unregister_event_source(struct stasis_app_event_source *obj)
Unregister an application event source.
static int __stasis_app_register(const char *app_name, stasis_app_cb handler, void *data, int all_events)
static int bridges_hash(const void *obj, const int flags)
static enum stasis_app_subscribe_res app_subscribe(struct stasis_app *app, const char *uri, struct stasis_app_event_source *event_source)
static int app_hash(const void *obj, const int flags)
enum stasis_app_subscribe_res stasis_app_subscribe_channel(const char *app_name, struct ast_channel *chan)
Directly subscribe an application to a channel.
void stasis_app_control_execute_until_exhausted(struct ast_channel *chan, struct stasis_app_control *control)
Act on a stasis app control queue until it is empty.
static int send_start_msg_snapshots(struct ast_channel *chan, struct stasis_app *app, int argc, char *argv[], struct ast_channel_snapshot *snapshot, struct ast_channel_snapshot *replace_channel_snapshot)
static const struct ast_datastore_info stasis_internal_channel_info
static int add_masquerade_store(struct ast_channel *chan)
struct ao2_container * app_bridges
struct ast_channel * stasis_app_bridge_moh_channel(struct ast_bridge *bridge)
Finds or creates an announcer channel in a bridge that can play music on hold.
enum stasis_app_user_event_res stasis_app_user_event(const char *app_name, const char *event_name, const char **source_uris, int sources_count, struct ast_json *json_variables)
Generate a Userevent for stasis app (echo to AMI)
#define APPS_NUM_BUCKETS
Number of buckets for the Stasis application hash table. Remember to keep it a prime number!
static int has_masquerade_store(struct ast_channel *chan)
int app_send_end_msg(struct stasis_app *app, struct ast_channel *chan)
Send StasisEnd message to the listening app.
void stasis_app_control_flush_queue(struct stasis_app_control *control)
Flush the control command queue.
static int control_hash(const void *obj, const int flags)
int stasis_app_channel_unreal_set_internal(struct ast_channel *chan)
Mark this unreal channel and it's other half as being internal to Stasis.
static struct ast_channel * prepare_bridge_moh_channel(void)
static int set_internal_datastore(struct ast_channel *chan)
#define CONTROLS_NUM_BUCKETS
Number of buckets for the Stasis application hash table. Remember to keep it a prime number!
static int append_name(void *obj, void *arg, int flags)
int stasis_app_bridge_playback_channel_add(struct ast_bridge *bridge, struct ast_channel *chan, struct stasis_app_control *control)
Adds a channel to the list of ARI playback channels for bridges.
void stasis_app_unregister(const char *app_name)
Unregister a Stasis application.
enum stasis_app_subscribe_res stasis_app_unsubscribe(const char *app_name, const char **event_source_uris, int event_sources_count, struct ast_json **json)
Unsubscribes an application from a list of event sources.
enum stasis_app_subscribe_res(* app_subscription_handler)(struct stasis_app *app, const char *uri, struct stasis_app_event_source *event_source)
struct stasis_message_sanitizer app_sanitizer
Sanitization callbacks for communication to Stasis applications.
static enum stasis_app_subscribe_res app_handle_subscriptions(const char *app_name, const char **event_source_uris, int event_sources_count, struct ast_json **json, app_subscription_handler handler)
struct stasis_app * stasis_app_get_by_name(const char *name)
Retrieve a handle to a Stasis application by its name.
static struct ast_json * app_event_sources_to_json(const struct stasis_app *app, struct ast_json *json)
struct stasis_app_control * stasis_app_control_find_by_channel_id(const char *channel_id)
Returns the handler for the channel with the given id.
static const struct ast_datastore_info masquerade_store_info
static int cleanup_cb(void *obj, void *arg, int flags)
static int bridges_channel_sort_fn(const void *obj_left, const void *obj_right, const int flags)
static void * moh_channel_thread(void *data)
void stasis_app_register_event_source(struct stasis_app_event_source *obj)
Register an application event source.
struct ast_channel * stasis_app_bridge_playback_channel_find(struct ast_bridge *bridge)
Finds an existing ARI playback channel in a bridge.
struct ao2_container * stasis_app_get_all(void)
Gets the names of all registered Stasis applications.
int stasis_app_control_is_done(struct stasis_app_control *control)
Check if a control is marked as done.
static int bridges_channel_compare(void *obj, void *arg, int flags)
static int load_module(void)
static void remove_masquerade_store(struct ast_channel *chan)
static void remove_bridge_playback(char *bridge_id)
static int unload_module(void)
static int masq_match_cb(void *obj, void *data, int flags)
static struct ast_bridge * bridge_create_common(const char *type, const char *name, const char *id, int invisible)
struct ast_datastore_info set_end_published_info
struct ao2_container * apps_registry
Stasis application container.
static struct stasis_app_event_source * app_event_source_find(const char *uri)
static int channel_id_sanitizer(const char *id)
Sanitization callback for channel unique IDs.
static void control_unlink(struct stasis_app_control *control)
In addition to running ao2_cleanup(), this function also removes the object from the app_controls con...
static struct replace_channel_store * get_replace_channel_store(struct ast_channel *chan, int no_create)
int stasis_app_channel_is_stasis_end_published(struct ast_channel *chan)
Has this channel had a StasisEnd published on it?
static struct ast_json * stasis_end_to_json(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
static int bridges_channel_hash_fn(const void *obj, const int flags)
struct stasis_app_control * stasis_app_control_find_by_channel(const struct ast_channel *chan)
Returns the handler for the given channel.
char * app_get_replace_channel_app(struct ast_channel *chan)
Get the app that the replacement channel will be controlled by.
int stasis_app_register_all(const char *app_name, stasis_app_cb handler, void *data)
Register a new Stasis application that receives all Asterisk events.
static struct ast_json * stasis_start_to_json(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
static int control_compare(void *obj, void *arg, int flags)
struct stasis_app_control * stasis_app_control_create(struct ast_channel *chan)
Creates a control handler for a channel that isn't in a stasis app.
int stasis_app_bridge_moh_stop(struct ast_bridge *bridge)
Breaks down MOH channels playing on the bridge created by stasis_app_bridge_moh_channel.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
#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.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
const char * stasis_app_control_get_channel_id(const struct stasis_app_control *control)
Returns the uniqueid of the channel associated with this control.
struct stasis_topic * ast_app_get_topic(struct stasis_app *app)
Returns the stasis topic for an app.
void stasis_app_unregister_event_sources(void)
Unregister core event sources.
stasis_app_user_event_res
Return code for stasis_app_user_event.
@ STASIS_APP_USER_APP_NOT_FOUND
@ STASIS_APP_USER_EVENT_SOURCE_NOT_FOUND
@ STASIS_APP_USER_EVENT_SOURCE_BAD_SCHEME
@ STASIS_APP_USER_INTERNAL_ERROR
struct ast_json * stasis_app_event_filter_to_json(struct stasis_app *app, struct ast_json *json)
Convert and add the app's event type filter(s) to the given json object.
void stasis_app_register_event_sources(void)
Register core event sources.
void(* stasis_app_cb)(void *data, const char *app_name, struct ast_json *message)
Callback for Stasis application handler.
struct ast_bridge * stasis_app_get_bridge(struct stasis_app_control *control)
Gets the bridge currently associated with a control object.
const char * stasis_app_name(const struct stasis_app *app)
Retrieve an application's name.
stasis_app_subscribe_res
Return code for stasis_app_[un]subscribe.
@ STASIS_ASR_EVENT_SOURCE_BAD_SCHEME
@ STASIS_ASR_INTERNAL_ERROR
@ STASIS_ASR_EVENT_SOURCE_NOT_FOUND
@ STASIS_ASR_APP_NOT_FOUND
void stasis_app_control_shutdown(void)
Let Stasis app internals shut down.
Backend API for implementing components of res_stasis.
struct ast_bridge * bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id, enum ast_bridge_video_mode_type video_mode, unsigned int send_sdp_label)
void bridge_stasis_init(void)
Internal API for the Stasis bridge subclass.
#define STASIS_BRIDGE_MIXING_CAPABILITIES
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *bridge_id)
Returns the current snapshot for the bridge.
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_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#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
String manipulation functions.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
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.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
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.
Registered applications container.
Structure that contains information about a bridge.
const ast_string_field uniqueid
Blob of data associated with a channel.
struct ast_channel_snapshot * snapshot
const ast_string_field uniqueid
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_base * base
Main Channel structure associated with a channel.
struct ast_bridge * bridge
Structure for a data store type.
Structure for a data store object.
Data structure associated with a single frame of data.
Abstract JSON element (object, array, string, int, ...).
A multi object blob data structure to carry user event stasis messages.
Options for ast_pbx_run()
unsigned int no_hangup_chan
The base pvt structure for local channel derivatives.
struct ast_channel * chan
struct ast_channel_snapshot * snapshot
struct ast_channel_snapshot * replace_channel
struct ast_channel_snapshot * channel
const ast_string_field bridge_id
const ast_string_field channel_id
struct ast_bridge * bridge
Event source information and callbacks.
const char * scheme
The scheme to match against on [un]subscribes.
int(* unsubscribe)(struct stasis_app *app, const char *id)
Cancel the subscription an app has to an event source.
void(* to_json)(const struct stasis_app *app, struct ast_json *json)
Convert event source data to json.
struct stasis_app_event_source * next
void *(* find)(const struct stasis_app *app, const char *id)
Find an event source data object by the given id/name.
int(* is_subscribed)(struct stasis_app *app, const char *id)
Find an event source by the given id/name.
int(* subscribe)(struct stasis_app *app, void *obj)
Subscribe an application to an event source.
Structure containing callbacks for Stasis message sanitization.
int(* channel)(const struct ast_channel *chan)
Callback which determines whether a channel should be sanitized from a message based on the channel.
int(* channel_snapshot)(const struct ast_channel_snapshot *snapshot)
Callback which determines whether a channel should be sanitized from a message based on the channel's...
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 void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_pthread_create_detached(a, b, c, d)