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",
186 static 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;
735 if (!
ao2_link(app_bridges_playback, new_wrapper)) {
765 if (!playback_wrapper) {
775 const char *bridge_id)
798 char *requested_type, *requested_types =
ast_strdupa(
S_OR(type,
"mixing"));
799 int capabilities = 0;
809 while ((requested_type =
strsep(&requested_types,
","))) {
810 requested_type =
ast_strip(requested_type);
812 if (!strcmp(requested_type,
"mixing")) {
815 }
else if (!strcmp(requested_type,
"holding")) {
817 }
else if (!strcmp(requested_type,
"dtmf_events") ||
818 !strcmp(requested_type,
"proxy_media")) {
820 }
else if (!strcmp(requested_type,
"video_sfu")) {
822 }
else if (!strcmp(requested_type,
"video_single")) {
842 if (!
ao2_link(app_bridges, bridge)) {
886 .
type =
"replace-channel-store",
897 if (!datastore && !no_create) {
909 if (!datastore->
data) {
913 ret = datastore->
data;
961 replace_channel_snapshot = replace->
snapshot;
964 return replace_channel_snapshot;
970 char *replace_channel_app;
976 replace_channel_app = replace->
app;
979 return replace_channel_app;
1025 payload->
blob = json_blob;
1031 for (i = 0; i < argc; ++i) {
1049 if (replace_channel_snapshot) {
1058 int argc,
char *argv[])
1089 if (sanitize && sanitize->
channel 1172 if (!new_snapshot) {
1179 if (!old_snapshot) {
1206 .
type =
"stasis-masqerade",
1284 .
type =
"stasis_end_published",
1307 return datastore ? 1 : 0;
1340 if (!apps_registry) {
1347 "Stasis app '%s' not registered\n", app_name);
1352 "Stasis app '%s' not active\n", app_name);
1358 ast_log(
LOG_ERROR,
"Control allocation failed or Stasis app '%s' not registered\n", app_name);
1381 "Error sending start message to '%s'\n", app_name);
1455 for (idx = 0; idx < next_argc; idx++) {
1495 "type",
"ApplicationMoveFailed",
1501 ast_log(
LOG_ERROR,
"Failed to pack JSON for ApplicationMoveFailed message\n");
1509 for (idx = 0; idx < next_argc; ++idx) {
1529 last_bridge = bridge;
1532 if (bridge != last_bridge) {
1572 ast_debug(3,
"%s: Hangup (no more frames)\n",
1646 memset(&pbx_args, 0,
sizeof(pbx_args));
1660 if (!apps_registry) {
1670 "Stasis app '%s' not registered\n", app_name);
1683 if (!apps_registry) {
1712 if (!apps_registry) {
1730 if (!apps_registry) {
1795 if (!apps_registry) {
1802 "Stasis app '%s' not registered\n", app_name);
1829 if (source == obj) {
1940 const char *
app_name,
const char **event_source_uris,
1941 int event_sources_count,
struct ast_json **json,
1953 for (i = 0; i < event_sources_count; ++i) {
1954 const char *uri = event_source_uris[i];
1959 if (!event_source) {
1966 res =
handler(app, uri, event_source);
1975 ast_debug(3,
"%s: Successful; setting results\n", app_name);
2026 ast_debug(3,
"%s: Checking %s\n", app_name, uri);
2029 (!event_source->
find || (!(obj = event_source->
find(app, uri + strlen(event_source->
scheme)))))) {
2034 ast_debug(3,
"%s: Subscribing to %s\n", app_name, uri);
2046 const char **event_source_uris,
int event_sources_count,
2050 app_name, event_source_uris, event_sources_count,
2069 const char *
id = uri + strlen(event_source->
scheme);
2076 ast_debug(3,
"%s: Unsubscribing from %s\n", app_name, uri);
2087 const char **event_source_uris,
int event_sources_count,
2091 app_name, event_source_uris, event_sources_count,
2096 const char *event_name,
2097 const char **source_uris,
int sources_count,
2105 int have_channel = 0;
2117 if (json_variables) {
2141 for (i = 0; i < sources_count; ++i) {
2142 const char *uri = source_uris[i];
2143 void *snapshot=
NULL;
2206 apps_registry =
NULL;
2209 app_controls =
NULL;
2215 app_bridges_moh =
NULL;
2218 app_bridges_playback =
NULL;
2270 .
type =
"stasis-internal-channel",
2357 if (!apps_registry || !app_controls || !app_bridges || !app_bridges_moh || !app_bridges_playback) {
static int bridges_channel_hash_fn(const void *obj, const int flags)
struct ast_bridge * stasis_app_get_bridge(struct stasis_app_control *control)
Gets the bridge currently associated with a control object.
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.
Options for ast_pbx_run()
#define ast_channel_lock(chan)
char * control_next_app(struct stasis_app_control *control)
Returns the name of the application we are moving to.
Main Channel structure associated with a channel.
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data)
Register a new Stasis application.
struct ast_channel_snapshot * snapshot
struct stasis_topic * ast_app_get_topic(struct stasis_app *app)
Returns the stasis topic for an app.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
struct ast_json * stasis_app_object_to_json(struct stasis_app *app)
Return the JSON representation of a Stasis application.
static void playback_after_bridge_cb(struct ast_channel *chan, void *data)
struct ast_channel_snapshot * replace_channel
char ** control_next_app_args(struct stasis_app_control *control)
Returns the list of arguments to pass to the application we are moving to.
static int channel_snapshot_sanitizer(const struct ast_channel_snapshot *snapshot)
struct ast_channel_snapshot_base * base
Asterisk main include file. File version handling, generic pbx functions.
int stasis_app_send(const char *app_name, struct ast_json *message)
Send a message to the given Stasis application.
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.
const ast_string_field uniqueid
struct ast_bridge * stasis_app_bridge_create(const char *type, const char *name, const char *id)
Create a bridge of the specified type.
struct ast_multi_object_blob * ast_multi_object_blob_create(struct ast_json *blob)
Create a stasis multi object blob.
void stasis_app_register_event_sources(void)
Register core event sources.
ast_bridge_video_mode_type
Video source modes.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
static struct ast_channel_snapshot * get_replace_channel_snapshot(struct ast_channel *chan)
static int bridges_channel_compare(void *obj, void *arg, int flags)
static int app_compare(void *obj, void *arg, int flags)
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.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
String manipulation functions.
void *(* find)(const struct stasis_app *app, const char *id)
Find an event source data object by the given id/name.
int stasis_app_control_is_done(struct stasis_app_control *control)
Check if a control is marked as done.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define ast_pthread_create_detached(a, b, c, d)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
Registered applications container.
The arg parameter is a search key, but is not an object.
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...
static int bridges_compare(void *obj, void *arg, int flags)
static struct stasis_app_event_source * app_event_source_find(const char *uri)
int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc, char *argv[])
Control a channel using stasis_app.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
static int unload_module(void)
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
struct ast_channel_snapshot * snapshot
const char * scheme
The scheme to match against on [un]subscribes.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
int(* channel_id)(const char *channel_id)
Callback which determines whether a channel should be sanitized from a message based on the channel's...
void control_mark_done(struct stasis_app_control *control)
int ast_check_hangup_locked(struct ast_channel *chan)
static int control_compare(void *obj, void *arg, int flags)
static int load_module(void)
#define ao2_callback(c, flags, cb_fn, arg)
static int channel_id_sanitizer(const char *id)
int messaging_cleanup(void)
Tidy up the messaging layer.
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 * app_bridges_moh
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.
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.
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)
void control_flush_queue(struct stasis_app_control *control)
Flush the control command queue.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
enum stasis_app_subscribe_res stasis_app_subscribe_channel(const char *app_name, struct ast_channel *chan)
Directly subscribe an application to a channel.
#define APPS_NUM_BUCKETS
Number of buckets for the Stasis application hash table. Remember to keep it a prime number! ...
void app_deactivate(struct stasis_app *app)
Deactivates an application.
Structure representing a snapshot of channel state.
struct ast_json * stasis_app_to_json(const char *app_name)
Return the JSON representation of a Stasis application.
#define ast_str_container_alloc(buckets)
Allocates a hash container for bare strings.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int stasis_app_channel_is_internal(struct ast_channel *chan)
Is this channel internal to Stasis?
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
Assume that the ao2_container is already locked.
Structure for a data store type.
static struct ast_channel * bridge_moh_create(struct ast_bridge *bridge)
int app_unsubscribe_channel(struct stasis_app *app, struct ast_channel *chan)
Cancel the subscription an app has for a channel.
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
static int __stasis_app_register(const char *app_name, stasis_app_cb handler, void *data, int all_events)
STASIS_MESSAGE_TYPE_DEFN_LOCAL(end_message_type,.to_json=stasis_end_to_json)
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.
const ast_string_field uniqueid
static int has_masquerade_store(struct ast_channel *chan)
void app_shutdown(struct stasis_app *app)
Tears down an application.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_link_flags(container, obj, flags)
static void remove_masquerade_store(struct ast_channel *chan)
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.
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
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.
#define BRIDGES_NUM_BUCKETS
Number of buckets for the Stasis bridges hash table. Remember to keep it a prime number! ...
struct ast_datastore_info set_end_published_info
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
int control_command_count(struct stasis_app_control *control)
Returns the count of items in a control's command queue.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
struct ao2_container * app_bridges
struct stasis_app * control_app(struct stasis_app_control *control)
Returns the pointer (non-reffed) to the app associated with this control.
const ast_string_field bridge_id
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.
#define ast_verb(level,...)
int app_is_active(struct stasis_app *app)
Checks whether an app is active.
Structure containing callbacks for Stasis message sanitization.
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...
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
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.
static struct ast_bridge * bridge_create_common(const char *type, const char *name, const char *id, int invisible)
struct stasis_app * stasis_app_get_by_name(const char *name)
Retrieve a handle to a Stasis application by its name.
int control_dispatch_all(struct stasis_app_control *control, struct ast_channel *chan)
Dispatch all commands enqueued to this control.
int app_subscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Add a bridge subscription to an existing channel subscription.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Blob of data associated with a channel.
static int control_hash(const void *obj, const int flags)
#define ast_strlen_zero(foo)
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.
void ast_frame_dtor(struct ast_frame *frame)
NULL-safe wrapper for ast_frfree, good for RAII_VAR.
struct ao2_container * app_controls
static int cleanup_cb(void *obj, void *arg, int flags)
int app_send_end_msg(struct stasis_app *app, struct ast_channel *chan)
Send StasisEnd message to the listening app.
ast_bridge_after_cb_reason
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)
void(* to_json)(const struct stasis_app *app, struct ast_json *json)
Convert event source data to json.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define ast_debug(level,...)
Log a DEBUG message.
static void cleanup(void)
Clean up any old apps that we don't need any more.
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
int stasis_app_channel_is_stasis_end_published(struct ast_channel *chan)
Has this channel had a StasisEnd published on it?
void control_move_cleanup(struct stasis_app_control *control)
Free any memory that was allocated for switching applications via /channels/{channelId}/move.
int(* unsubscribe)(struct stasis_app *app, const char *id)
Cancel the subscription an app has to an event source.
A multi object blob data structure to carry user event stasis messages.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
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.
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.
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
Event source information and callbacks.
struct ao2_container * stasis_app_get_all(void)
Gets the names of all registered Stasis applications.
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
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 stasis_app_control_shutdown(void)
Let Stasis app internals shut down.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define AST_CAUSE_NORMAL_CLEARING
#define AST_STRING_FIELD(name)
Declare a string field.
const char * stasis_app_name(const struct stasis_app *app)
Retrieve an application's name.
#define ao2_ref(o, delta)
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.
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
static struct ast_json * stasis_end_to_json(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
#define AST_RWLIST_REMOVE_CURRENT
#define ast_strdupa(s)
duplicate a string in memory from the stack
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
stasis_user_multi_object_snapshot_type
Object type code for multi user object snapshots.
int(* channel)(const struct ast_channel *chan)
Callback which determines whether a channel should be sanitized from a message based on the channel...
int app_unsubscribe_channel_id(struct stasis_app *app, const char *channel_id)
Cancel the subscription an app has for a channel.
void stasis_app_register_event_source(struct stasis_app_event_source *obj)
Register an application event source.
Channels with this particular technology are an implementation detail of Asterisk and should generall...
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.
Internal API for the Stasis application controller.
int app_is_finished(struct stasis_app *app)
Checks whether a deactivated app has no channels.
int messaging_init(void)
Initialize the messaging layer.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
static const struct ast_datastore_info stasis_internal_channel_info
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
#define CONTROLS_NUM_BUCKETS
Number of buckets for the Stasis application hash table. Remember to keep it a prime number! ...
int ast_channel_fdno(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
Structure that contains information about a bridge.
static int send_start_msg(struct stasis_app *app, struct ast_channel *chan, int argc, char *argv[])
struct stasis_message_sanitizer app_sanitizer
Backend API for implementing components of res_stasis.
void app_send(struct stasis_app *app, struct ast_json *message)
Send a message to the given application.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
struct ao2_container * app_bridges_playback
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.
const char * stasis_app_control_get_channel_id(const struct stasis_app_control *control)
Returns the uniqueid of the channel associated with this control.
void stasis_app_channel_set_stasis_end_published(struct ast_channel *chan)
Indicate that this channel has had a StasisEnd published for it.
#define ao2_unlink(container, obj)
Internal API for the Stasis bridge subclass.
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.
static void channel_stolen_cb(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
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.
struct ast_bridge * stasis_app_bridge_find_by_id(const char *bridge_id)
Returns the bridge with the given id.
void stasis_app_unregister(const char *app_name)
Unregister a Stasis application.
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
The base pvt structure for local channel derivatives.
static const struct ast_datastore_info replace_channel_store_info
struct stasis_app_control * control_create(struct ast_channel *channel, struct stasis_app *app)
Create a control object.
const char * app_name(struct ast_app *app)
#define ao2_alloc(data_size, destructor_fn)
static const struct ast_datastore_info masquerade_store_info
const ast_string_field channel_id
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.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define ast_channel_unlock(chan)
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.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
#define STASIS_BRIDGE_MIXING_CAPABILITIES
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.
#define ast_calloc(num, len)
A wrapper for calloc()
void stasis_app_control_flush_queue(struct stasis_app_control *control)
Flush the control command queue.
struct ast_bridge * bridge
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
int stasis_app_channel_set_internal(struct ast_channel *chan)
Mark this channel as being internal to Stasis.
static int append_name(void *obj, void *arg, int flags)
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...
Module has failed to load, may be in an inconsistent state.
#define ao2_find(container, arg, flags)
stasis_app_subscribe_res
Return code for stasis_app_[un]subscribe.
void control_set_app(struct stasis_app_control *control, struct stasis_app *app)
Set the application the control object belongs to.
static void playback_after_bridge_cb_failed(enum ast_bridge_after_cb_reason reason, void *data)
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
void(* stasis_app_cb)(void *data, const char *app_name, struct ast_json *message)
Callback for Stasis application handler.
void stasis_app_bridge_destroy(const char *bridge_id)
Destroy the bridge.
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.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
void control_silence_stop_now(struct stasis_app_control *control)
Stop playing silence to a channel right now.
struct stasis_message_type * ast_multi_user_event_type(void)
Message type for custom user defined events with multi object blobs.
int control_is_done(struct stasis_app_control *control)
Returns true if control_continue() has been called on this control.
struct ast_channel_snapshot * channel
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.
enum stasis_app_subscribe_res(* app_subscription_handler)(struct stasis_app *app, const char *uri, struct stasis_app_event_source *event_source)
The arg parameter is an object of the same type.
struct stasis_app_control * stasis_app_control_find_by_channel(const struct ast_channel *chan)
Returns the handler for the given channel.
char * strsep(char **str, const char *delims)
struct ast_json * app_to_json(const struct stasis_app *app)
Create a JSON representation of a stasis_app.
After Bridge Execution API.
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.
static int bridges_channel_sort_fn(const void *obj_left, const void *obj_right, const int flags)
#define ao2_replace(dst, src)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
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...
stasis_app_user_event_res
Return code for stasis_app_user_event.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
int app_unsubscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Cancel the bridge subscription for an application.
Internal API for the Stasis application controller.
struct ao2_container * apps_registry
Stasis application container.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
const char * ast_channel_name(const struct ast_channel *chan)
static int set_internal_datastore(struct ast_channel *chan)
void app_update(struct stasis_app *app, stasis_app_cb handler, void *data)
Update the handler and data for a res_stasis application.
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)
static int masq_match_cb(void *obj, void *data, int flags)
static int app_hash(const void *obj, const int flags)
struct stasis_app_event_source * next
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.
Stasis out-of-call text message support.
Data structure associated with a single frame of data.
#define ao2_unlink_flags(container, obj, flags)
Internal Asterisk hangup causes.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Abstract JSON element (object, array, string, int, ...).
int app_subscribe_channel(struct stasis_app *app, struct ast_channel *chan)
Subscribes an application to a channel.
static int bridges_hash(const void *obj, const int flags)
#define ast_datastore_alloc(info, uid)
Reject objects with duplicate keys in container.
static void remove_bridge_playback(char *bridge_id)
void bridge_stasis_init(void)
static int add_masquerade_store(struct ast_channel *chan)
static struct ast_channel * prepare_bridge_moh_channel(void)
static struct stasis_app * find_app_by_name(const char *app_name)
Search option field mask.
static struct ast_json * app_event_sources_to_json(const struct stasis_app *app, struct ast_json *json)
void stasis_app_unregister_event_sources(void)
Unregister core event sources.
static enum stasis_app_subscribe_res app_subscribe(struct stasis_app *app, const char *uri, struct stasis_app_event_source *event_source)
int(* is_subscribed)(struct stasis_app *app, const char *id)
Find an event source by the given id/name.
static void start_message_blob_dtor(void *obj)
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
static void channel_replaced_cb(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Asterisk module definitions.
unsigned int no_hangup_chan
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)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
static void remove_stasis_end_published(struct ast_channel *chan)
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
void stasis_app_unregister_event_source(struct stasis_app_event_source *obj)
Unregister an application event source.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
static enum stasis_app_subscribe_res app_unsubscribe(struct stasis_app *app, const char *uri, struct stasis_app_event_source *event_source)
char * app_get_replace_channel_app(struct ast_channel *chan)
Get the app that the replacement channel will be controlled by.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
static void stasis_app_bridge_channel_wrapper_destructor(void *obj)
int(* subscribe)(struct stasis_app *app, void *obj)
Subscribe an application to an event source.
#define AST_RWLIST_TRAVERSE_SAFE_END
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.
int control_prestart_dispatch_all(struct stasis_app_control *control, struct ast_channel *chan)
Dispatch all queued prestart commands.
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)
static void * moh_channel_thread(void *data)
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.
static struct ast_json * stasis_start_to_json(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
static struct replace_channel_store * get_replace_channel_store(struct ast_channel *chan, int no_create)
static void replace_channel_destroy(void *obj)
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *bridge_id)
Returns the current snapshot for the bridge.
static int channel_sanitizer(const struct ast_channel *chan)
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
void control_wait(struct stasis_app_control *control)
Blocks until control's command queue has a command available.
#define ao2_link(container, obj)
Unreal channel derivative framework.
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.