Asterisk - The Open Source Telephony Project
18.5.0
|
Internal API for the Stasis application controller. More...
Go to the source code of this file.
Enumerations | |
enum | stasis_app_subscription_model { STASIS_APP_SUBSCRIBE_MANUAL, STASIS_APP_SUBSCRIBE_ALL } |
Functions | |
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. More... | |
void | app_deactivate (struct stasis_app *app) |
Deactivates an application. More... | |
char * | app_get_replace_channel_app (struct ast_channel *chan) |
Get the app that the replacement channel will be controlled by. More... | |
int | app_is_active (struct stasis_app *app) |
Checks whether an app is active. More... | |
int | app_is_finished (struct stasis_app *app) |
Checks whether a deactivated app has no channels. More... | |
int | app_is_subscribed_bridge_id (struct stasis_app *app, const char *bridge_id) |
Test if an app is subscribed to a bridge. More... | |
int | app_is_subscribed_channel_id (struct stasis_app *app, const char *channel_id) |
Test if an app is subscribed to a channel. More... | |
int | app_is_subscribed_endpoint_id (struct stasis_app *app, const char *endpoint_id) |
Test if an app is subscribed to a endpoint. More... | |
void | app_send (struct stasis_app *app, struct ast_json *message) |
Send a message to an application. More... | |
int | app_send_end_msg (struct stasis_app *app, struct ast_channel *chan) |
Send StasisEnd message to the listening app. More... | |
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. More... | |
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. More... | |
void | app_shutdown (struct stasis_app *app) |
Tears down an application. More... | |
int | app_subscribe_bridge (struct stasis_app *app, struct ast_bridge *bridge) |
Add a bridge subscription to an existing channel subscription. More... | |
int | app_subscribe_channel (struct stasis_app *app, struct ast_channel *chan) |
Subscribes an application to a channel. More... | |
int | app_subscribe_endpoint (struct stasis_app *app, struct ast_endpoint *endpoint) |
Subscribes an application to a endpoint. More... | |
struct ast_json * | app_to_json (const struct stasis_app *app) |
Create a JSON representation of a stasis_app . More... | |
int | app_unsubscribe_bridge (struct stasis_app *app, struct ast_bridge *bridge) |
Cancel the bridge subscription for an application. More... | |
int | app_unsubscribe_bridge_id (struct stasis_app *app, const char *bridge_id) |
Cancel the subscription an app has for a bridge. More... | |
int | app_unsubscribe_channel (struct stasis_app *app, struct ast_channel *chan) |
Cancel the subscription an app has for a channel. More... | |
int | app_unsubscribe_channel_id (struct stasis_app *app, const char *channel_id) |
Cancel the subscription an app has for a channel. More... | |
int | app_unsubscribe_endpoint_id (struct stasis_app *app, const char *endpoint_id) |
Cancel the subscription an app has for a endpoint. More... | |
void | app_update (struct stasis_app *app, stasis_app_cb handler, void *data) |
Update the handler and data for a res_stasis application. More... | |
Enumerator | |
---|---|
STASIS_APP_SUBSCRIBE_MANUAL | |
STASIS_APP_SUBSCRIBE_ALL |
Definition at line 39 of file res/stasis/app.h.
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.
name | Name of the application. |
handler | Callback for messages sent to the application. |
data | Data pointer provided to the callback. |
res_stasis
application. NULL
on error. Definition at line 915 of file res/stasis/app.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_alloc_options, ao2_bump, ao2_cleanup, AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT, ao2_container_alloc_rbtree, ao2_ref, app, app_dtor(), ast_add_extension(), ast_asprintf, ast_assert, ast_attended_transfer_type(), ast_blind_transfer_type(), ast_bridge_merge_message_type(), ast_bridge_snapshot_type(), ast_bridge_topic_all(), ast_channel_snapshot_type(), ast_context_find(), ast_context_find_or_create(), ast_endpoint_snapshot_type(), ast_free, ast_free_ptr(), ast_log, ast_strdup, ast_verb, bridge_attended_transfer_handler(), bridge_blind_transfer_handler(), bridge_merge_handler(), bridge_subscription_change_handler(), context_name, forwards_sort(), stasis_app::handler, LOG_WARNING, NULL, RAII_VAR, stasis_message_router_add(), stasis_message_router_add_cache_update(), stasis_message_router_create, stasis_message_router_set_formatters_default(), stasis_subscription_change_type(), STASIS_SUBSCRIPTION_FORMATTER_JSON, stasis_topic_create(), sub_bridge_update_handler(), sub_channel_update_handler(), sub_default_handler(), sub_endpoint_update_handler(), sub_subscription_change_handler(), and stasis_app::subscription_model.
Referenced by __stasis_app_register().
void app_deactivate | ( | struct stasis_app * | app | ) |
Deactivates an application.
Any channels currently in the application remain active (since the app might come back), but new channels are rejected.
app | Application to deactivate. |
Definition at line 1066 of file res/stasis/app.c.
References ao2_cleanup, ao2_lock, ao2_unlock, ast_verb, stasis_app::data, stasis_app::handler, stasis_app::name, and NULL.
Referenced by stasis_app_unregister().
char* app_get_replace_channel_app | ( | struct ast_channel * | chan | ) |
Get the app that the replacement channel will be controlled by.
channel | The channel on which this will be set |
NULL | on error |
Definition at line 967 of file res_stasis.c.
References replace_channel_store::app, get_replace_channel_store(), NULL, and replace().
Referenced by bridge_stasis_run_cb().
int app_is_active | ( | struct stasis_app * | app | ) |
Checks whether an app is active.
app | Application to check. |
Definition at line 1094 of file res/stasis/app.c.
References ao2_lock, ao2_unlock, stasis_app::handler, and NULL.
Referenced by stasis_app_exec().
int app_is_finished | ( | struct stasis_app * | app | ) |
Checks whether a deactivated app has no channels.
app | Application to check. |
True | (non-zero) if app is deactivated, and has no associated channels. |
False | (zero) otherwise. |
Definition at line 1105 of file res/stasis/app.c.
References ao2_container_count(), ao2_lock, ao2_unlock, stasis_app::forwards, stasis_app::handler, and NULL.
Referenced by app_shutdown(), and cleanup_cb().
int app_is_subscribed_bridge_id | ( | struct stasis_app * | app, |
const char * | bridge_id | ||
) |
Test if an app is subscribed to a bridge.
app | Subscribing application. |
bridge_id | Id of bridge to check. |
Definition at line 1504 of file res/stasis/app.c.
References ao2_cleanup, ao2_find, ast_strlen_zero, BRIDGE_ALL, stasis_app::forwards, NULL, and OBJ_SEARCH_KEY.
int app_is_subscribed_channel_id | ( | struct stasis_app * | app, |
const char * | channel_id | ||
) |
Test if an app is subscribed to a channel.
app | Subscribing application. |
channel_id | Id of channel to check. |
Definition at line 1402 of file res/stasis/app.c.
References ao2_cleanup, ao2_find, ast_strlen_zero, CHANNEL_ALL, stasis_app::forwards, NULL, and OBJ_SEARCH_KEY.
int app_is_subscribed_endpoint_id | ( | struct stasis_app * | app, |
const char * | endpoint_id | ||
) |
Test if an app is subscribed to a endpoint.
app | Subscribing application. |
endpoint_id | Id of endpoint to check. |
Definition at line 1601 of file res/stasis/app.c.
References ao2_cleanup, ao2_find, ast_strlen_zero, ENDPOINT_ALL, stasis_app::forwards, NULL, and OBJ_SEARCH_KEY.
void app_send | ( | struct stasis_app * | app, |
struct ast_json * | message | ||
) |
Send a message to an application.
app | Application. |
message | Message to send. |
Send a message to an application.
app | App to send the message to. |
message | Message to send. |
Definition at line 1038 of file res/stasis/app.c.
References ao2_bump, ao2_cleanup, ao2_lock, ao2_unlock, ast_eid_default, ast_eid_to_str(), ast_json_object_get(), ast_json_object_set(), ast_json_string_create(), ast_json_string_get(), ast_log, AST_LOG_WARNING, ast_verb, stasis_app::data, stasis_app::handler, and stasis_app::name.
Referenced by app_update(), message_received_handler(), stasis_app_exec(), stasis_app_send(), sub_bridge_update_handler(), sub_channel_update_handler(), sub_default_handler(), and sub_endpoint_update_handler().
int app_send_end_msg | ( | struct stasis_app * | app, |
struct ast_channel * | chan | ||
) |
Send StasisEnd message to the listening app.
app | The app that owns the channel |
chan | The channel for which the message is being sent |
zero | on success |
Definition at line 1083 of file res_stasis.c.
References ao2_cleanup, app_unsubscribe_channel(), ast_app_get_topic(), ast_channel_blob_create(), ast_json_pack(), ast_json_timeval(), ast_json_unref(), ast_log, ast_tvnow(), start_message_blob::blob, stasis_message_sanitizer::channel, LOG_ERROR, NULL, remove_masquerade_store(), stasis_app_get_sanitizer(), stasis_app_name(), and stasis_publish().
Referenced by bridge_stasis_moving(), channel_replaced_cb(), channel_stolen_cb(), and stasis_app_exec().
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.
channel | The channel on which this will be set |
replace_app | The app that will be controlling this channel |
zero | success |
non-zero | failure |
Definition at line 931 of file res_stasis.c.
References replace_channel_store::app, ast_free, ast_strdup, get_replace_channel_store(), NULL, and replace().
Referenced by bridge_stasis_push_peek().
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.
channel | The channel on which this will be set |
replace_snapshot | The snapshot of the channel that is being replaced |
zero | success |
non-zero | failure |
Definition at line 919 of file res_stasis.c.
References ao2_replace, get_replace_channel_store(), replace(), and replace_channel_store::snapshot.
Referenced by bridge_stasis_push_peek().
void app_shutdown | ( | struct stasis_app * | app | ) |
Tears down an application.
It should be finished before calling this.
app | Application to unsubscribe. |
Definition at line 1078 of file res/stasis/app.c.
References ao2_lock, ao2_unlock, app_is_finished(), ast_assert, stasis_app::bridge_router, stasis_app::endpoint_router, NULL, stasis_app::router, and stasis_message_router_unsubscribe().
Referenced by cleanup_cb().
int app_subscribe_bridge | ( | struct stasis_app * | app, |
struct ast_bridge * | bridge | ||
) |
Add a bridge subscription to an existing channel subscription.
app | Application. |
bridge | Bridge to subscribe to. |
Definition at line 1428 of file res/stasis/app.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_debug, BRIDGE_ALL, stasis_app::forwards, forwards_create_bridge(), app_forwards::interested, stasis_app::name, OBJ_NOLOCK, OBJ_SEARCH_KEY, and ast_bridge::uniqueid.
Referenced by control_swap_channel_in_bridge(), stasis_app_exec(), and subscribe_bridge().
int app_subscribe_channel | ( | struct stasis_app * | app, |
struct ast_channel * | chan | ||
) |
Subscribes an application to a channel.
app | Application. |
chan | Channel to subscribe to. |
Definition at line 1281 of file res/stasis/app.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_channel_uniqueid(), ast_debug, CHANNEL_ALL, stasis_app::forwards, forwards_create_channel(), app_forwards::interested, stasis_app::name, OBJ_NOLOCK, and OBJ_SEARCH_KEY.
Referenced by call_forwarded_handler(), send_start_msg_snapshots(), stasis_app_subscribe_channel(), and subscribe_channel().
int app_subscribe_endpoint | ( | struct stasis_app * | app, |
struct ast_endpoint * | endpoint | ||
) |
Subscribes an application to a endpoint.
app | Application. |
chan | Endpoint to subscribe to. |
Definition at line 1531 of file res/stasis/app.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_debug, ast_endpoint_get_id(), ENDPOINT_ALL, stasis_app::forwards, forwards_create_endpoint(), app_forwards::interested, message_received_handler(), messaging_app_subscribe_endpoint(), stasis_app::name, OBJ_NOLOCK, and OBJ_SEARCH_KEY.
Referenced by subscribe_endpoint().
struct ast_json* app_to_json | ( | const struct stasis_app * | app | ) |
Create a JSON representation of a stasis_app
.
app | The application |
JSON
blob on success NULL
on error Definition at line 1228 of file res/stasis/app.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, array(), ast_json_array_append(), ast_json_object_get(), ast_json_pack(), ast_json_string_create(), ast_json_unref(), ast_log, bridges, channels, endpoints, FORWARD_BRIDGE, FORWARD_CHANNEL, FORWARD_ENDPOINT, app_forwards::forward_type, stasis_app::forwards, app_forwards::id, LOG_ERROR, stasis_app::name, and NULL.
Referenced by stasis_app_object_to_json().
int app_unsubscribe_bridge | ( | struct stasis_app * | app, |
struct ast_bridge * | bridge | ||
) |
Cancel the bridge subscription for an application.
forwards | Return from app_subscribe_channel(). |
bridge | Bridge to subscribe to. |
Definition at line 1486 of file res/stasis/app.c.
References app_unsubscribe_bridge_id(), BRIDGE_ALL, and ast_bridge::uniqueid.
Referenced by internal_bridge_after_cb(), and stasis_app_exec().
int app_unsubscribe_bridge_id | ( | struct stasis_app * | app, |
const char * | bridge_id | ||
) |
Cancel the subscription an app has for a bridge.
app | Subscribing application. |
bridge_id | Id of bridge to unsubscribe from. |
Definition at line 1495 of file res/stasis/app.c.
References unsubscribe().
Referenced by app_unsubscribe_bridge().
int app_unsubscribe_channel | ( | struct stasis_app * | app, |
struct ast_channel * | chan | ||
) |
Cancel the subscription an app has for a channel.
app | Subscribing application. |
chan | Channel to unsubscribe from. |
Definition at line 1384 of file res/stasis/app.c.
References app_unsubscribe_channel_id(), ast_channel_uniqueid(), and CHANNEL_ALL.
Referenced by app_send_end_msg().
int app_unsubscribe_channel_id | ( | struct stasis_app * | app, |
const char * | channel_id | ||
) |
Cancel the subscription an app has for a channel.
app | Subscribing application. |
channel_id | Id of channel to unsubscribe from. |
Definition at line 1393 of file res/stasis/app.c.
References unsubscribe().
Referenced by app_unsubscribe_channel(), and send_start_msg_snapshots().
int app_unsubscribe_endpoint_id | ( | struct stasis_app * | app, |
const char * | endpoint_id | ||
) |
Cancel the subscription an app has for a endpoint.
app | Subscribing application. |
endpoint_id | Id of endpoint to unsubscribe from. |
Definition at line 1592 of file res/stasis/app.c.
References unsubscribe().
void app_update | ( | struct stasis_app * | app, |
stasis_app_cb | handler, | ||
void * | data | ||
) |
Update the handler and data for a res_stasis
application.
If app has been deactivated, this will reactivate it.
app | Application to update. |
handler | New application callback. |
data | New data pointer for the callback. |
Definition at line 1116 of file res/stasis/app.c.
References ao2_lock, ao2_replace, ao2_unlock, app_send(), ast_json_pack(), ast_json_timeval(), ast_json_unref(), ast_tvnow(), ast_verb, stasis_app::data, stasis_app::handler, stasis_app::name, and NULL.
Referenced by __stasis_app_register().