Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
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... | |
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. |
subscription_model |
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, stasis_app::data, forwards_sort(), handler(), LOG_WARNING, name, 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 1061 of file res/stasis/app.c.
References ao2_cleanup, ao2_lock, ao2_unlock, app, ast_verb, 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.
chan | The channel on which this will be set |
NULL | on error |
Definition at line 970 of file res_stasis.c.
References 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. |
True | (non-zero) if app is active. |
False | (zero) if app has been deactivated. |
Definition at line 1089 of file res/stasis/app.c.
References ao2_lock, ao2_unlock, app, 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 1100 of file res/stasis/app.c.
References ao2_container_count(), ao2_lock, ao2_unlock, app, 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. |
True | (non-zero) if bridge is subscribed to app. |
False | (zero) if bridge is not subscribed. |
Definition at line 1499 of file res/stasis/app.c.
References ao2_cleanup, ao2_find, app, ast_strlen_zero(), BRIDGE_ALL, 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. |
True | (non-zero) if channel is subscribed to app. |
False | (zero) if channel is not subscribed. |
Definition at line 1397 of file res/stasis/app.c.
References ao2_cleanup, ao2_find, app, ast_strlen_zero(), CHANNEL_ALL, 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. |
True | (non-zero) if endpoint is subscribed to app. |
False | (zero) if endpoint is not subscribed. |
Definition at line 1596 of file res/stasis/app.c.
References ao2_cleanup, ao2_find, app, ast_strlen_zero(), ENDPOINT_ALL, NULL, and OBJ_SEARCH_KEY.
void app_send | ( | struct stasis_app * | app, |
struct ast_json * | message | ||
) |
Send a message to an application.
app | App to send the message to. |
message | Message to send. |
Definition at line 1033 of file res/stasis/app.c.
References ao2_bump, ao2_cleanup, ao2_lock, ao2_unlock, app, 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, and handler().
Referenced by app_update(), message_received_handler(), stasis_app_exec(), stasis_app_send(), sub_bridge_update_handler(), sub_channel_update_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 1086 of file res_stasis.c.
References ao2_cleanup, app, app_unsubscribe_channel(), ast_app_get_topic(), ast_channel_blob_create(), ast_json_pack(), ast_json_timeval(), ast_json_unref(), ast_log, ast_tvnow(), 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.
chan | 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 934 of file res_stasis.c.
References 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.
chan | 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 922 of file res_stasis.c.
References ao2_replace, get_replace_channel_store(), and replace().
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 1073 of file res/stasis/app.c.
References ao2_lock, ao2_unlock, app, app_is_finished(), ast_assert, NULL, 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. |
0 | on success. |
Non-zero | on error. |
Definition at line 1423 of file res/stasis/app.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, app, ast_debug, BRIDGE_ALL, forwards_create_bridge(), app_forwards::interested, 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. |
0 | on success. |
Non-zero | on error. |
Definition at line 1276 of file res/stasis/app.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, app, ast_channel_uniqueid(), ast_debug, CHANNEL_ALL, forwards_create_channel(), app_forwards::interested, 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. |
endpoint | Endpoint to subscribe to. |
0 | on success. |
Non-zero | on error. |
Definition at line 1526 of file res/stasis/app.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, app, ast_debug, ast_endpoint_get_id(), ENDPOINT_ALL, forwards_create_endpoint(), app_forwards::interested, message_received_handler(), messaging_app_subscribe_endpoint(), 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 |
NULL | on error |
Definition at line 1223 of file res/stasis/app.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, app, 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, app_forwards::id, LOG_ERROR, 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.
app | Subscribing application. |
bridge | Bridge to subscribe to. |
0 | on success. |
Non-zero | on error. |
Definition at line 1481 of file res/stasis/app.c.
References app, 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. |
0 | on success. |
Non-zero | on error. |
Definition at line 1490 of file res/stasis/app.c.
References app, and 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. |
0 | on success. |
Non-zero | on error. |
Definition at line 1379 of file res/stasis/app.c.
References app, 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. |
0 | on success. |
Non-zero | on error. |
Definition at line 1388 of file res/stasis/app.c.
References app, and 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. |
0 | on success. |
Non-zero | on error. |
Definition at line 1587 of file res/stasis/app.c.
References app, and 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 1111 of file res/stasis/app.c.
References ao2_lock, ao2_replace, ao2_unlock, app, app_send(), ast_json_pack(), ast_json_timeval(), ast_json_unref(), ast_tvnow(), ast_verb, handler(), and NULL.
Referenced by __stasis_app_register().