|
Asterisk - The Open Source Telephony Project GIT-master-590b490
|
Stasis Application Broadcast API. More...


Go to the source code of this file.
Macros | |
| #define | STASIS_BROADCAST_FLAG_SUPPRESS_CLAIMED (1 << 0) |
| Suppress CallClaimed event for this broadcast. | |
Functions | |
| int AST_OPTIONAL_API_NAME() | stasis_app_broadcast_channel (struct ast_channel *chan, int timeout_ms, const char *app_filter, unsigned int flags) |
| Start a broadcast for a channel. | |
| void AST_OPTIONAL_API_NAME() | stasis_app_broadcast_cleanup (const char *channel_id) |
| Clean up broadcast context for a channel. | |
| int AST_OPTIONAL_API_NAME() | stasis_app_broadcast_wait (struct ast_channel *chan, int timeout_ms) |
| Wait for a broadcast channel to be claimed. | |
| char *AST_OPTIONAL_API_NAME() | stasis_app_broadcast_winner (const char *channel_id) |
| Get the winner app name for a broadcast channel. | |
| int AST_OPTIONAL_API_NAME() | stasis_app_claim_channel (const char *channel_id, const char *app_name) |
| Attempt to claim a broadcast channel. | |
Stasis Application Broadcast API.
This module provides the infrastructure for broadcasting incoming channels to multiple ARI applications and handling first-claim winner logic.
Definition in file stasis_app_broadcast.h.
| #define STASIS_BROADCAST_FLAG_SUPPRESS_CLAIMED (1 << 0) |
Suppress CallClaimed event for this broadcast.
Definition at line 36 of file stasis_app_broadcast.h.
| int AST_OPTIONAL_API_NAME() stasis_app_broadcast_channel | ( | struct ast_channel * | chan, |
| int | timeout_ms, | ||
| const char * | app_filter, | ||
| unsigned int | flags | ||
| ) |
Start a broadcast for a channel.
Broadcasts a channel to all ARI applications (or filtered applications) allowing them to claim the channel. Only the first claim will succeed.
When a channel is claimed, a CallClaimed event is sent only to applications that matched the app_filter (or all apps if no filter was set). This can be suppressed entirely with STASIS_BROADCAST_FLAG_SUPPRESS_CLAIMED.
| chan | The channel to broadcast |
| timeout_ms | Timeout in milliseconds to wait for a claim |
| app_filter | Optional regex filter for application names (NULL for all) |
| flags | Combination of STASIS_BROADCAST_FLAG_* values |
| 0 | on success |
| -1 | on error |
| AST_OPTIONAL_API_UNAVAILABLE | if res_stasis_broadcast is not loaded |
| chan | The channel to broadcast |
| timeout_ms | Timeout in milliseconds |
| app_filter | Optional regex filter for applications |
Definition at line 550 of file res_stasis_broadcast.c.
References ao2_bump, ao2_cleanup, ao2_link, ao2_unlink, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_uniqueid(), ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), ast_debug, ast_log, broadcast_contexts, broadcast_ctx_create(), broadcast_datastore_info, ast_datastore::data, LOG_ERROR, NULL, RAII_VAR, and send_broadcast_event().
Referenced by stasis_broadcast_exec().
| void AST_OPTIONAL_API_NAME() stasis_app_broadcast_cleanup | ( | const char * | channel_id | ) |
Clean up broadcast context for a channel.
Removes the broadcast context when the channel is done or leaving the broadcast state.
| channel_id | The unique ID of the channel |
This is the normal-path cleanup called by the dialplan application after the broadcast completes. The channel datastore destructor (broadcast_datastore_destroy) also unlinks the context as a safety net for abnormal teardown; ao2_unlink is idempotent so the double call is harmless.
| channel_id | The unique ID of the channel |
Definition at line 885 of file res_stasis_broadcast.c.
References ao2_cleanup, ao2_find, ast_debug, ast_strlen_zero(), broadcast_contexts, NULL, OBJ_SEARCH_KEY, OBJ_UNLINK, and RAII_VAR.
Referenced by stasis_broadcast_exec().
| int AST_OPTIONAL_API_NAME() stasis_app_broadcast_wait | ( | struct ast_channel * | chan, |
| int | timeout_ms | ||
| ) |
Wait for a broadcast channel to be claimed.
Blocks until the channel is claimed or the timeout expires.
| chan | The channel |
| timeout_ms | Maximum time to wait in milliseconds |
| 0 | if claimed within timeout |
| -1 | if timeout expired or error |
| AST_OPTIONAL_API_UNAVAILABLE | if res_stasis_broadcast is not loaded |
Blocks until the channel is claimed, the timeout expires, or the channel hangs up. The hangup check runs every BROADCAST_POLL_INTERVAL_MS so that a dead channel does not tie up a PBX thread for the full timeout period.
| chan | The channel |
| timeout_ms | Maximum time to wait in milliseconds |
Definition at line 782 of file res_stasis_broadcast.c.
References ao2_cleanup, ao2_find, ao2_lock, ao2_object_get_lockaddr(), ao2_unlock, ast_channel_uniqueid(), ast_check_hangup(), ast_cond_timedwait, ast_debug, ast_log, ast_tv(), ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), broadcast_contexts, BROADCAST_POLL_INTERVAL_MS, LOG_WARNING, MAX_BROADCAST_TIMEOUT_MS, NULL, OBJ_SEARCH_KEY, RAII_VAR, result, and wait_result().
Referenced by stasis_broadcast_exec().
| char *AST_OPTIONAL_API_NAME() stasis_app_broadcast_winner | ( | const char * | channel_id | ) |
Get the winner app name for a broadcast channel.
| channel_id | The unique ID of the channel |
| NULL | if res_stasis_broadcast is not loaded |
| channel_id | The unique ID of the channel |
Definition at line 743 of file res_stasis_broadcast.c.
References ao2_cleanup, ao2_find, ao2_lock, ao2_unlock, ast_strdup, ast_strlen_zero(), broadcast_contexts, NULL, OBJ_SEARCH_KEY, and RAII_VAR.
Referenced by stasis_broadcast_exec().
| int AST_OPTIONAL_API_NAME() stasis_app_claim_channel | ( | const char * | channel_id, |
| const char * | app_name | ||
| ) |
Attempt to claim a broadcast channel.
Atomically attempts to claim a channel that is in broadcast state. Only the first claim for a given channel will succeed.
| channel_id | The unique ID of the channel |
| app_name | The name of the application claiming the channel |
| 0 | if claim successful |
| -1 | if channel not found |
| -2 | if already claimed by another application |
| AST_OPTIONAL_API_UNAVAILABLE | if res_stasis_broadcast is not loaded |
| channel_id | The unique ID of the channel |
| app_name | The name of the application claiming the channel |
Definition at line 637 of file res_stasis_broadcast.c.
References ao2_cleanup, ao2_find, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, app_name(), ast_channel_snapshot_get_latest(), ast_channel_snapshot_to_json(), ast_cond_signal, ast_debug, ast_json_deep_copy(), ast_json_pack(), ast_json_timeval(), ast_json_unref(), ast_log, ast_strdup, ast_strlen_zero(), ast_tvnow(), ast_verb, broadcast_contexts, LOG_ERROR, NULL, OBJ_SEARCH_KEY, RAII_VAR, stasis_app_get_all(), stasis_app_send(), and STASIS_BROADCAST_FLAG_SUPPRESS_CLAIMED.
Referenced by ast_ari_events_claim_channel().