Asterisk - The Open Source Telephony Project
21.4.1
|
Stasis application control support. More...
#include "asterisk.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/stasis_app.h"
#include "command.h"
#include "control.h"
#include "app.h"
#include "asterisk/dial.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_after.h"
#include "asterisk/bridge_basic.h"
#include "asterisk/bridge_features.h"
#include "asterisk/frame.h"
#include "asterisk/pbx.h"
#include "asterisk/musiconhold.h"
#include "asterisk/app.h"
#include <signal.h>
Go to the source code of this file.
Data Structures | |
struct | app_control_rules |
struct | chanvar |
structure for queuing ARI channel variable setting More... | |
struct | control_dial_args |
struct | stasis_app_control |
struct | stasis_app_control_continue_data |
struct | stasis_app_control_dtmf_data |
struct | stasis_app_control_move_data |
struct | stasis_app_control_mute_data |
Typedefs | |
typedef int(* | app_command_can_exec_cb) (struct stasis_app_control *control) |
Functions | |
static int | add_to_dial_bridge (struct stasis_app_control *control, struct ast_channel *chan) |
Add a channel to the singleton dial bridge. More... | |
static int | app_control_add_role (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_can_add_channel_to_bridge (struct stasis_app_control *control) |
static int | app_control_can_remove_channel_from_bridge (struct stasis_app_control *control) |
static enum stasis_app_control_channel_result | app_control_check_rules (const struct stasis_app_control *control, struct app_control_rules *list) |
static int | app_control_clear_roles (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_continue (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_dial (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_dtmf (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_hold (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_moh_start (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_moh_stop (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_move (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_mute (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_redirect (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static void | app_control_register_rule (struct stasis_app_control *control, struct app_control_rules *list, struct stasis_app_control_rule *obj) |
static int | app_control_remove_channel_from_bridge (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_ring (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_ring_stop (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_set_channel_var (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_silence_start (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_silence_stop (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_unhold (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | app_control_unmute (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static void | app_control_unregister_rule (struct stasis_app_control *control, struct app_control_rules *list, struct stasis_app_control_rule *obj) |
static int | app_send_command_on_condition (struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor, app_command_can_exec_cb can_exec_fn) |
static void | bridge_after_cb (struct ast_channel *chan, void *data) |
static void | bridge_after_cb_failed (enum ast_bridge_after_cb_reason reason, void *data) |
static int | bridge_channel_depart (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | bridge_timeout (struct ast_bridge_channel *bridge_channel, void *ignore) |
Dial timeout. More... | |
int | control_add_channel_to_bridge (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
Command callback for adding a channel to a bridge. More... | |
struct stasis_app * | control_app (struct stasis_app_control *control) |
Returns the pointer (non-reffed) to the app associated with this control. More... | |
int | control_command_count (struct stasis_app_control *control) |
Returns the count of items in a control's command queue. More... | |
struct stasis_app_control * | control_create (struct ast_channel *channel, struct stasis_app *app) |
Create a control object. More... | |
static struct control_dial_args * | control_dial_args_alloc (const char *dialstring, unsigned int timeout) |
static void | control_dial_args_destroy (void *data) |
int | control_dispatch_all (struct stasis_app_control *control, struct ast_channel *chan) |
Dispatch all commands enqueued to this control. More... | |
static void | control_dtor (void *obj) |
void | control_flush_queue (struct stasis_app_control *control) |
Flush the control command queue. More... | |
int | control_is_done (struct stasis_app_control *control) |
Returns true if control_continue() has been called on this control. More... | |
void | control_mark_done (struct stasis_app_control *control) |
void | control_move_cleanup (struct stasis_app_control *control) |
Free any memory that was allocated for switching applications via /channels/{channelId}/move. More... | |
char * | control_next_app (struct stasis_app_control *control) |
Returns the name of the application we are moving to. More... | |
char ** | control_next_app_args (struct stasis_app_control *control) |
Returns the list of arguments to pass to the application we are moving to. More... | |
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. More... | |
int | control_prestart_dispatch_all (struct stasis_app_control *control, struct ast_channel *chan) |
Dispatch all queued prestart commands. More... | |
void | control_set_app (struct stasis_app_control *control, struct stasis_app *app) |
Set the application the control object belongs to. More... | |
void | control_set_thread (struct stasis_app_control *control, pthread_t threadid) |
set the control's thread id More... | |
void | control_silence_stop_now (struct stasis_app_control *control) |
Stop playing silence to a channel right now. More... | |
int | control_swap_channel_in_bridge (struct stasis_app_control *control, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap) |
Command for swapping a channel in a bridge. More... | |
void | control_wait (struct stasis_app_control *control) |
Blocks until control's command queue has a command available. More... | |
static int | depart_channel (struct stasis_app_control *control, struct ast_channel *chan) |
Depart a channel from a bridge, and potentially add it back to the dial bridge. More... | |
static void | dial_bridge_after_cb (struct ast_channel *chan, void *data) |
after bridge callback for the dial bridge More... | |
static void | dial_bridge_after_cb_failed (enum ast_bridge_after_cb_reason reason, void *data) |
static void | dtmf_in_bridge (struct ast_channel *chan, struct stasis_app_control_dtmf_data *dtmf_data) |
static void | dtmf_no_bridge (struct ast_channel *chan, struct stasis_app_control_dtmf_data *dtmf_data) |
static struct stasis_app_command * | exec_command (struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor) |
static struct stasis_app_command * | exec_command_on_condition (struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor, app_command_can_exec_cb can_exec_fn) |
static void | free_chanvar (void *data) |
static struct ast_bridge * | get_dial_bridge (void) |
Retrieve a reference to the dial bridge. More... | |
static int | hangup_channel (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static void | internal_bridge_after_cb (struct ast_channel *chan, void *data, enum ast_bridge_after_cb_reason reason) |
static int | noop_cb (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static void | set_interval_hook (struct ast_channel *chan) |
Set a dial timeout interval hook on the channel. More... | |
static int | set_timeout (struct ast_channel *chan, unsigned int timeout) |
Set dial timeout on a channel to be dialed. More... | |
void | stasis_app_control_absorb_dtmf_in_bridge (struct stasis_app_control *control, int absorb) |
Set whether DTMF from the channel is absorbed instead of passing through to the bridge. More... | |
int | stasis_app_control_add_channel_to_bridge (struct stasis_app_control *control, struct ast_bridge *bridge) |
Add a channel to the bridge. More... | |
int | stasis_app_control_add_role (struct stasis_app_control *control, const char *role) |
Apply a bridge role to a channel controlled by a stasis app control. More... | |
int | stasis_app_control_bridge_features_init (struct stasis_app_control *control) |
Initialize bridge features into a channel control. More... | |
void | stasis_app_control_clear_roles (struct stasis_app_control *control) |
Clear bridge roles currently applied to a channel controlled by a stasis app control. More... | |
int | stasis_app_control_continue (struct stasis_app_control *control, const char *context, const char *extension, int priority) |
Exit res_stasis and continue execution in the dialplan. More... | |
int | stasis_app_control_dial (struct stasis_app_control *control, const char *dialstring, unsigned int timeout) |
Dial a channel. More... | |
int | stasis_app_control_dtmf (struct stasis_app_control *control, const char *dtmf, int before, int between, unsigned int duration, int after) |
Send DTMF to the channel associated with this control. More... | |
const char * | stasis_app_control_get_channel_id (const struct stasis_app_control *control) |
Returns the uniqueid of the channel associated with this control. More... | |
struct ast_channel_snapshot * | stasis_app_control_get_snapshot (const struct stasis_app_control *control) |
Returns the most recent snapshot for the associated channel. More... | |
void | stasis_app_control_hold (struct stasis_app_control *control) |
Place the channel associated with the control on hold. More... | |
void | stasis_app_control_inhibit_colp_in_bridge (struct stasis_app_control *control, int inhibit_colp) |
Set whether COLP frames should be generated when joining the bridge. More... | |
void | stasis_app_control_moh_start (struct stasis_app_control *control, const char *moh_class) |
Play music on hold to a channel (does not affect hold status) More... | |
void | stasis_app_control_moh_stop (struct stasis_app_control *control) |
Stop playing music on hold to a channel (does not affect hold status) More... | |
int | stasis_app_control_move (struct stasis_app_control *control, const char *app_name, const char *app_args) |
Exit res_stasis and move to another Stasis application. More... | |
int | stasis_app_control_mute (struct stasis_app_control *control, unsigned int direction, enum ast_frame_type frametype) |
Mute the channel associated with this control. More... | |
void | stasis_app_control_mute_in_bridge (struct stasis_app_control *control, int mute) |
Set whether audio from the channel is muted instead of passing through to the bridge. More... | |
void | stasis_app_control_publish (struct stasis_app_control *control, struct stasis_message *message) |
Publish a message to the control's channel's topic. More... | |
int | stasis_app_control_queue_control (struct stasis_app_control *control, enum ast_control_frame_type frame_type) |
Queue a control frame without payload. More... | |
int | stasis_app_control_redirect (struct stasis_app_control *control, const char *endpoint) |
Redirect a channel in res_stasis to a particular endpoint. More... | |
void | stasis_app_control_register_add_rule (struct stasis_app_control *control, struct stasis_app_control_rule *rule) |
Registers an add channel to bridge rule. More... | |
void | stasis_app_control_register_remove_rule (struct stasis_app_control *control, struct stasis_app_control_rule *rule) |
Registers a remove channel from bridge rule. More... | |
int | stasis_app_control_remove_channel_from_bridge (struct stasis_app_control *control, struct ast_bridge *bridge) |
Remove a channel from the bridge. More... | |
int | stasis_app_control_ring (struct stasis_app_control *control) |
Indicate ringing to the channel associated with this control. More... | |
int | stasis_app_control_ring_stop (struct stasis_app_control *control) |
Stop locally generated ringing on the channel associated with this control. More... | |
int | stasis_app_control_set_channel_var (struct stasis_app_control *control, const char *variable, const char *value) |
Set a variable on the channel associated with this control to value. More... | |
void | stasis_app_control_shutdown (void) |
Let Stasis app internals shut down. More... | |
void | stasis_app_control_silence_start (struct stasis_app_control *control) |
Start playing silence to a channel. More... | |
void | stasis_app_control_silence_stop (struct stasis_app_control *control) |
Stop playing silence to a channel. More... | |
void | stasis_app_control_unhold (struct stasis_app_control *control) |
Remove the channel associated with the control from hold. More... | |
int | stasis_app_control_unmute (struct stasis_app_control *control, unsigned int direction, enum ast_frame_type frametype) |
Unmute the channel associated with this control. More... | |
void | stasis_app_control_unregister_add_rule (struct stasis_app_control *control, struct stasis_app_control_rule *rule) |
UnRegister an add channel to bridge rule. More... | |
void | stasis_app_control_unregister_remove_rule (struct stasis_app_control *control, struct stasis_app_control_rule *rule) |
Unregisters a remove channel from bridge rule. More... | |
struct ast_bridge * | stasis_app_get_bridge (struct stasis_app_control *control) |
Gets the bridge currently associated with a control object. More... | |
int | stasis_app_send_command (struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor) |
Invokes a command on a control's channel. More... | |
int | stasis_app_send_command_async (struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor) |
Asynchronous version of stasis_app_send_command(). More... | |
Variables | |
static struct ast_bridge * | dial_bridge |
Singleton dial bridge. More... | |
static ast_mutex_t | dial_bridge_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static int | shutting_down |
Indicates if the Stasis app internals are being shut down. | |
struct ast_datastore_info | timeout_datastore |
Dial timeout datastore. More... | |
Stasis application control support.
Definition in file control.c.
typedef int(* app_command_can_exec_cb) (struct stasis_app_control *control) |
|
static |
Add a channel to the singleton dial bridge.
control | The Stasis control structure |
chan | The channel to add to the bridge |
-1 | Failed |
0 | Success |
Definition at line 1063 of file control.c.
References ao2_ref, ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_DEPARTABLE, ast_bridge_set_after_callback(), stasis_app_control::bridge, dial_bridge_after_cb(), and get_dial_bridge().
Referenced by depart_channel().
|
static |
Dial timeout.
This is a bridge interval hook callback. The interval hook triggering means that the dial timeout has been reached. If the channel has not been answered by the time this callback is called, then the channel is hung up
bridge_channel | Bridge channel on which interval hook has been called |
ignore | Ignored |
Definition at line 1237 of file control.c.
References ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_datastore_free(), AST_STATE_UP, ast_bridge_channel::chan, RAII_VAR, stasis_app_control_find_by_channel(), and stasis_app_send_command_async().
Referenced by set_interval_hook().
int control_add_channel_to_bridge | ( | struct stasis_app_control * | control, |
struct ast_channel * | chan, | ||
void * | data | ||
) |
Command callback for adding a channel to a bridge.
control | The control for chan |
chan | The channel on which commands should be executed |
data | Bridge to be passed to the callback |
Definition at line 1400 of file control.c.
References control_swap_channel_in_bridge().
Referenced by stasis_app_control_add_channel_to_bridge().
struct stasis_app* control_app | ( | struct stasis_app_control * | control | ) |
Returns the pointer (non-reffed) to the app associated with this control.
control | Control to query. |
Definition at line 1585 of file control.c.
References stasis_app_control::app.
Referenced by stasis_app_exec().
int control_command_count | ( | struct stasis_app_control * | control | ) |
Returns the count of items in a control's command queue.
control | Control to count commands on |
Definition at line 365 of file control.c.
References ao2_container_count(), and stasis_app_control::command_queue.
Referenced by stasis_app_control_execute_until_exhausted().
struct stasis_app_control* control_create | ( | struct ast_channel * | channel, |
struct stasis_app * | app | ||
) |
Create a control object.
channel | Channel to control. |
app | stasis_app for which this control is being created. |
NULL | on error. |
Definition at line 129 of file control.c.
References stasis_app_control::add_rules, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_bump, ao2_container_alloc_list, ao2_ref, stasis_app_control::app, ast_channel_ref, AST_LIST_HEAD_INIT, AST_VECTOR_INIT, stasis_app_control::channel, stasis_app_control::command_queue, control_set_thread(), stasis_app_control::next_app, stasis_app_control::next_app_args, and stasis_app_control::remove_rules.
Referenced by stasis_app_control_create(), and stasis_app_exec().
int control_dispatch_all | ( | struct stasis_app_control * | control, |
struct ast_channel * | chan | ||
) |
Dispatch all commands enqueued to this control.
control | Control object to dispatch. |
chan | Associated channel. |
Definition at line 1517 of file control.c.
References ao2_iterator_destroy(), ao2_iterator_init(), AO2_ITERATOR_UNLINK, ao2_ref, stasis_app_control::channel, and stasis_app_control::command_queue.
Referenced by stasis_app_control_execute_until_exhausted(), and stasis_app_exec().
void control_flush_queue | ( | struct stasis_app_control * | control | ) |
Flush the control command queue.
control | Control object to flush command queue. |
Definition at line 1504 of file control.c.
References ao2_iterator_destroy(), ao2_iterator_init(), AO2_ITERATOR_UNLINK, ao2_ref, and stasis_app_control::command_queue.
Referenced by stasis_app_control_flush_queue(), and stasis_app_exec().
int control_is_done | ( | struct stasis_app_control * | control | ) |
Returns true if control_continue() has been called on this control.
control | Control to query. |
True | (non-zero) if control_continue() has been called. |
False | (zero) otherwise. |
Definition at line 370 of file control.c.
References stasis_app_control::is_done.
Referenced by stasis_app_control_execute_until_exhausted(), stasis_app_control_is_done(), and stasis_app_exec().
void control_move_cleanup | ( | struct stasis_app_control * | control | ) |
Free any memory that was allocated for switching applications via /channels/{channelId}/move.
control | The control for the channel |
Definition at line 1724 of file control.c.
References ast_free_ptr(), AST_VECTOR_RESET, stasis_app_control::next_app, and stasis_app_control::next_app_args.
Referenced by stasis_app_exec().
char* control_next_app | ( | struct stasis_app_control * | control | ) |
Returns the name of the application we are moving to.
control | The control for the channel |
Definition at line 1719 of file control.c.
References stasis_app_control::next_app.
Referenced by stasis_app_exec().
char** control_next_app_args | ( | struct stasis_app_control * | control | ) |
Returns the list of arguments to pass to the application we are moving to.
control | The control for the channel |
Definition at line 1732 of file control.c.
References AST_VECTOR_STEAL_ELEMENTS, and stasis_app_control::next_app_args.
Referenced by stasis_app_exec().
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.
control | The control for the channel |
Definition at line 1737 of file control.c.
References AST_VECTOR_SIZE, and stasis_app_control::next_app_args.
Referenced by stasis_app_exec().
int control_prestart_dispatch_all | ( | struct stasis_app_control * | control, |
struct ast_channel * | chan | ||
) |
Dispatch all queued prestart commands.
control | The control for chan |
chan | The channel on which commands should be executed |
Definition at line 1557 of file control.c.
References ao2_iterator_destroy(), ao2_iterator_init(), AO2_ITERATOR_UNLINK, command_prestart_get_container(), and stasis_app_control::command_queue.
Referenced by stasis_app_exec().
void control_set_app | ( | struct stasis_app_control * | control, |
struct stasis_app * | app | ||
) |
Set the application the control object belongs to.
control | The control for the channel |
app | The application this control will now belong to |
Definition at line 1713 of file control.c.
References ao2_bump, and stasis_app_control::app.
Referenced by stasis_app_exec().
void control_set_thread | ( | struct stasis_app_control * | control, |
pthread_t | threadid | ||
) |
set the control's thread id
control | Control object on which to set the thread id. |
threadid | id to set |
Definition at line 196 of file control.c.
References stasis_app_control::command_queue, and stasis_app_control::control_thread.
Referenced by control_create(), and stasis_app_exec().
void control_silence_stop_now | ( | struct stasis_app_control * | control | ) |
Stop playing silence to a channel right now.
control | The control for chan |
Definition at line 859 of file control.c.
References ast_channel_stop_silence_generator(), ast_debug, stasis_app_control::channel, stasis_app_control::silgen, and stasis_app_control_get_channel_id().
Referenced by stasis_app_exec().
int control_swap_channel_in_bridge | ( | struct stasis_app_control * | control, |
struct ast_bridge * | bridge, | ||
struct ast_channel * | chan, | ||
struct ast_channel * | swap | ||
) |
Command for swapping a channel in a bridge.
control | The control for chan |
chan | The channel on which commands should be executed |
bridge | Bridge to be passed to the callback |
swap | Channel to swap with when joining the bridge |
Definition at line 1306 of file control.c.
References stasis_app_control::app, app_subscribe_bridge(), ast_bridge_depart(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_DEPARTABLE, AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP, ast_bridge_set_after_callback(), ast_debug, stasis_app_control::bridge, stasis_app_control::bridge_features, ast_bridge_features::inhibit_colp, stasis_app_control::pbx, set_interval_hook(), stasis_app_control_get_channel_id(), stasis_app_get_bridge(), and ast_bridge::uniqueid.
Referenced by control_add_channel_to_bridge().
void control_wait | ( | struct stasis_app_control * | control | ) |
Blocks until control's command queue has a command available.
control | Control to block on. |
Definition at line 1537 of file control.c.
References ao2_container_count(), ao2_object_get_lockaddr(), and stasis_app_control::command_queue.
Referenced by stasis_app_exec().
|
static |
Depart a channel from a bridge, and potentially add it back to the dial bridge.
control | Take a guess |
chan | Take another guess |
Definition at line 1091 of file control.c.
References add_to_dial_bridge(), ast_bridge_depart(), ast_check_hangup(), and AST_STATE_UP.
|
static |
after bridge callback for the dial bridge
The only purpose of this callback is to ensure that the control structure's bridge pointer is NULLed
Definition at line 1031 of file control.c.
References __ao2_cleanup(), ast_channel_get_bridge_channel(), ast_debug, stasis_app_control::bridge, stasis_app_control::channel, and stasis_app_send_command_async().
Referenced by add_to_dial_bridge().
|
static |
Retrieve a reference to the dial bridge.
If the dial bridge has not been created yet, it will be created, otherwise, a reference to the existing bridge will be returned.
The caller will need to unreference the dial bridge once they are finished with it.
NULL | Unable to find/create the dial bridge |
non-NULL | A reference to the dial bridge |
Definition at line 996 of file control.c.
References ao2_bump, shutting_down, and stasis_app_bridge_create_invisible().
Referenced by add_to_dial_bridge().
|
static |
Set a dial timeout interval hook on the channel.
The absolute time that the timeout should occur is stored on a datastore on the channel. This time is converted into a relative number of milliseconds in the future. Then an interval hook is set to trigger in that number of milliseconds.
chan | The channel on which to set the interval hook |
Definition at line 1276 of file control.c.
References ao2_ref, ast_bridge_interval_hook(), ast_channel_datastore_find(), ast_channel_get_bridge_channel(), ast_null_frame, ast_queue_frame(), ast_tvdiff_ms(), ast_tvnow(), bridge_timeout(), ast_bridge_channel::chan, ast_datastore::data, and ast_bridge_channel::features.
Referenced by control_swap_channel_in_bridge(), and set_timeout().
|
static |
Set dial timeout on a channel to be dialed.
chan | The channel on which to set the dial timeout |
timeout | The timeout in seconds |
Definition at line 1625 of file control.c.
References ast_channel_datastore_add(), ast_channel_is_bridged(), ast_malloc, ast_samp2tv(), ast_tvadd(), ast_tvnow(), ast_datastore::data, and set_interval_hook().
void stasis_app_control_absorb_dtmf_in_bridge | ( | struct stasis_app_control * | control, |
int | absorb | ||
) |
Set whether DTMF from the channel is absorbed instead of passing through to the bridge.
control | Control whose channel should have its DTMF absorbed when bridged |
absorb | Whether DTMF should be absorbed (1) instead of passed through (0). |
Definition at line 1486 of file control.c.
References stasis_app_control::bridge_features, and ast_bridge_features::dtmf_passthrough.
Referenced by ast_ari_bridges_add_channel().
int stasis_app_control_add_channel_to_bridge | ( | struct stasis_app_control * | control, |
struct ast_bridge * | bridge | ||
) |
Add a channel to the bridge.
control | Control whose channel should be added to the bridge |
bridge | Pointer to the bridge |
Definition at line 1405 of file control.c.
References ast_debug, control_add_channel_to_bridge(), and stasis_app_control_get_channel_id().
Referenced by ast_ari_bridges_add_channel().
int stasis_app_control_add_role | ( | struct stasis_app_control * | control, |
const char * | role | ||
) |
Apply a bridge role to a channel controlled by a stasis app control.
control | Control for res_stasis |
role | Role to apply |
Definition at line 338 of file control.c.
References ast_free_ptr(), ast_strdup, and stasis_app_send_command_async().
Referenced by ast_ari_bridges_add_channel().
int stasis_app_control_bridge_features_init | ( | struct stasis_app_control * | control | ) |
Initialize bridge features into a channel control.
control | Control in which to store the features |
Definition at line 1473 of file control.c.
References ast_bridge_features_new(), and stasis_app_control::bridge_features.
Referenced by ast_ari_bridges_add_channel().
void stasis_app_control_clear_roles | ( | struct stasis_app_control * | control | ) |
Clear bridge roles currently applied to a channel controlled by a stasis app control.
control | Control for res_stasis |
Definition at line 360 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_bridges_add_channel().
int stasis_app_control_continue | ( | struct stasis_app_control * | control, |
const char * | context, | ||
const char * | extension, | ||
int | priority | ||
) |
Exit res_stasis
and continue execution in the dialplan.
If the channel is no longer in res_stasis
, this function does nothing.
control | Control for res_stasis |
context | An optional context to continue to |
extension | An optional extension to continue to |
priority | An optional priority to continue to |
Definition at line 411 of file control.c.
References ast_calloc, ast_copy_string(), ast_free_ptr(), S_OR, and stasis_app_send_command_async().
Referenced by ast_ari_channels_continue_in_dialplan().
int stasis_app_control_dial | ( | struct stasis_app_control * | control, |
const char * | dialstring, | ||
unsigned int | timeout | ||
) |
Dial a channel.
control | Control for res_stasis . |
dialstring | The dialstring to pass to the channel driver |
timeout | Optional timeout in milliseconds |
Definition at line 1688 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_dial().
int stasis_app_control_dtmf | ( | struct stasis_app_control * | control, |
const char * | dtmf, | ||
int | before, | ||
int | between, | ||
unsigned int | duration, | ||
int | after | ||
) |
Send DTMF to the channel associated with this control.
control | Control for res_stasis . |
dtmf | DTMF string. |
before | Amount of time to wait before sending DTMF digits. |
between | Amount of time between each DTMF digit. |
duration | Amount of time each DTMF digit lasts for. |
after | Amount of time to wait after sending DTMF digits. |
Definition at line 587 of file control.c.
References ast_calloc, ast_free_ptr(), and stasis_app_send_command_async().
Referenced by ast_ari_channels_send_dtmf().
const char* stasis_app_control_get_channel_id | ( | const struct stasis_app_control * | control | ) |
Returns the uniqueid of the channel associated with this control.
control | Control object. |
NULL | if control is NULL . |
Definition at line 1452 of file control.c.
References stasis_app_control::channel.
Referenced by control_compare(), control_hash(), control_silence_stop_now(), control_swap_channel_in_bridge(), stasis_app_control_add_channel_to_bridge(), stasis_app_control_answer(), stasis_app_control_get_snapshot(), stasis_app_control_play_uri(), stasis_app_control_record(), and stasis_app_control_remove_channel_from_bridge().
struct ast_channel_snapshot* stasis_app_control_get_snapshot | ( | const struct stasis_app_control * | control | ) |
Returns the most recent snapshot for the associated channel.
The returned pointer is AO2 managed, so ao2_cleanup() when you're done.
control | Control for res_stasis . |
NULL | if channel isn't in cache. |
Definition at line 882 of file control.c.
References ast_channel_snapshot_get_latest(), and stasis_app_control_get_channel_id().
Referenced by ari_bridges_play_helper(), ast_ari_channels_continue_in_dialplan(), and channel_state_invalid().
void stasis_app_control_hold | ( | struct stasis_app_control * | control | ) |
Place the channel associated with the control on hold.
control | Control for res_stasis . |
Definition at line 770 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_hold().
void stasis_app_control_inhibit_colp_in_bridge | ( | struct stasis_app_control * | control, |
int | inhibit_colp | ||
) |
Set whether COLP frames should be generated when joining the bridge.
control | Control whose channel should have its COLP frames inhibited when bridged |
inhibit_colp | Whether COLP frames should be generated (0) or not (1). |
Definition at line 1498 of file control.c.
References stasis_app_control::bridge_features, and ast_bridge_features::inhibit_colp.
Referenced by ast_ari_bridges_add_channel().
void stasis_app_control_moh_start | ( | struct stasis_app_control * | control, |
const char * | moh_class | ||
) |
Play music on hold to a channel (does not affect hold status)
control | Control for res_stasis . |
moh_class | class of music on hold to play (NULL allowed) |
Definition at line 802 of file control.c.
References ast_free_ptr(), ast_strdup, and stasis_app_send_command_async().
Referenced by ast_ari_channels_start_moh().
void stasis_app_control_moh_stop | ( | struct stasis_app_control * | control | ) |
Stop playing music on hold to a channel (does not affect hold status)
control | Control for res_stasis . |
Definition at line 820 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_stop_moh().
int stasis_app_control_move | ( | struct stasis_app_control * | control, |
const char * | app_name, | ||
const char * | app_args | ||
) |
Exit res_stasis
and move to another Stasis application.
If the channel is no longer in res_stasis
, this function does nothing.
control | Control for res_stasis |
app_name | The name of the application to switch to |
app_args | The list of arguments to pass to the application |
Definition at line 473 of file control.c.
References ast_calloc, ast_free_ptr(), and stasis_app_send_command_async().
Referenced by ast_ari_channels_move().
int stasis_app_control_mute | ( | struct stasis_app_control * | control, |
unsigned int | direction, | ||
enum ast_frame_type | frametype | ||
) |
Mute the channel associated with this control.
control | Control for res_stasis . |
direction | The direction in which the audio should be muted. |
frametype | The type of stream that should be muted. |
Definition at line 653 of file control.c.
References ast_calloc, ast_free_ptr(), and stasis_app_send_command_async().
Referenced by ast_ari_channels_mute().
void stasis_app_control_mute_in_bridge | ( | struct stasis_app_control * | control, |
int | mute | ||
) |
Set whether audio from the channel is muted instead of passing through to the bridge.
control | Control whose channel should have its audio muted when bridged |
mute | Whether audio should be muted (1) instead of passed through (0). |
Definition at line 1492 of file control.c.
References stasis_app_control::bridge_features, and ast_bridge_features::mute.
Referenced by ast_ari_bridges_add_channel().
void stasis_app_control_publish | ( | struct stasis_app_control * | control, |
struct stasis_message * | message | ||
) |
Publish a message to the control's channel's topic.
control | Control to publish to |
message | Message to publish |
Definition at line 1458 of file control.c.
References ast_channel_topic(), stasis_app_control::channel, and stasis_publish().
int stasis_app_control_queue_control | ( | struct stasis_app_control * | control, |
enum ast_control_frame_type | frame_type | ||
) |
Queue a control frame without payload.
control | Control to publish to. |
frame_type | type of control frame. |
Definition at line 1467 of file control.c.
References ast_queue_control(), and stasis_app_control::channel.
int stasis_app_control_redirect | ( | struct stasis_app_control * | control, |
const char * | endpoint | ||
) |
Redirect a channel in res_stasis
to a particular endpoint.
control | Control for res_stasis |
endpoint | The endpoint transfer string where the channel should be sent to |
Definition at line 522 of file control.c.
References ast_free_ptr(), ast_strdup, and stasis_app_send_command_async().
Referenced by ast_ari_channels_redirect().
void stasis_app_control_register_add_rule | ( | struct stasis_app_control * | control, |
struct stasis_app_control_rule * | rule | ||
) |
Registers an add channel to bridge rule.
control | Control object |
rule | The rule to register |
Definition at line 232 of file control.c.
References stasis_app_control::add_rules.
Referenced by stasis_app_control_record().
void stasis_app_control_register_remove_rule | ( | struct stasis_app_control * | control, |
struct stasis_app_control_rule * | rule | ||
) |
Registers a remove channel from bridge rule.
control | Control object |
rule | The rule to register |
Definition at line 246 of file control.c.
References stasis_app_control::remove_rules.
int stasis_app_control_remove_channel_from_bridge | ( | struct stasis_app_control * | control, |
struct ast_bridge * | bridge | ||
) |
Remove a channel from the bridge.
control | Control whose channel should be removed from the bridge |
bridge | Pointer to the bridge |
Definition at line 1442 of file control.c.
References ast_debug, and stasis_app_control_get_channel_id().
Referenced by ast_ari_bridges_remove_channel().
int stasis_app_control_ring | ( | struct stasis_app_control * | control | ) |
Indicate ringing to the channel associated with this control.
control | Control for res_stasis . |
Definition at line 614 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_ring().
int stasis_app_control_ring_stop | ( | struct stasis_app_control * | control | ) |
Stop locally generated ringing on the channel associated with this control.
control | Control for res_stasis . |
Definition at line 629 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_ring_stop().
int stasis_app_control_set_channel_var | ( | struct stasis_app_control * | control, |
const char * | variable, | ||
const char * | value | ||
) |
Set a variable on the channel associated with this control to value.
control | Control for res_stasis . |
variable | The name of the variable |
value | The value to set the variable to |
Definition at line 733 of file control.c.
References ast_calloc, ast_strdup, chanvar::name, stasis_app_send_command_async(), and chanvar::value.
Referenced by ast_ari_channels_set_channel_var().
void stasis_app_control_shutdown | ( | void | ) |
Let Stasis app internals shut down.
This is called when res_stasis is unloaded. It ensures that the Stasis app internals can free any resources they may have allocated during the time that res_stasis was loaded.
Definition at line 1702 of file control.c.
References ast_bridge_destroy(), and shutting_down.
void stasis_app_control_silence_start | ( | struct stasis_app_control * | control | ) |
Start playing silence to a channel.
control | Control for res_stasis . |
Definition at line 854 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_start_silence().
void stasis_app_control_silence_stop | ( | struct stasis_app_control * | control | ) |
Stop playing silence to a channel.
control | Control for res_stasis . |
Definition at line 877 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_stop_silence().
void stasis_app_control_unhold | ( | struct stasis_app_control * | control | ) |
Remove the channel associated with the control from hold.
control | Control for res_stasis . |
Definition at line 783 of file control.c.
References stasis_app_send_command_async().
Referenced by ast_ari_channels_unhold().
int stasis_app_control_unmute | ( | struct stasis_app_control * | control, |
unsigned int | direction, | ||
enum ast_frame_type | frametype | ||
) |
Unmute the channel associated with this control.
control | Control for res_stasis . |
direction | The direction in which the audio should be unmuted. |
frametype | The type of stream that should be unmuted. |
Definition at line 681 of file control.c.
References ast_calloc, ast_free_ptr(), and stasis_app_send_command_async().
Referenced by ast_ari_channels_unmute().
void stasis_app_control_unregister_add_rule | ( | struct stasis_app_control * | control, |
struct stasis_app_control_rule * | rule | ||
) |
UnRegister an add channel to bridge rule.
control | Control object |
rule | The rule to unregister |
Definition at line 239 of file control.c.
References stasis_app_control::add_rules.
void stasis_app_control_unregister_remove_rule | ( | struct stasis_app_control * | control, |
struct stasis_app_control_rule * | rule | ||
) |
Unregisters a remove channel from bridge rule.
control | Control object |
rule | The rule to unregister |
Definition at line 253 of file control.c.
References stasis_app_control::remove_rules.
struct ast_bridge* stasis_app_get_bridge | ( | struct stasis_app_control * | control | ) |
Gets the bridge currently associated with a control object.
control | Control object for the channel to query. |
NULL | if not associated with a bridge. |
Definition at line 953 of file control.c.
References stasis_app_control::bridge.
Referenced by ast_ari_bridges_remove_channel(), ast_ari_bridges_set_video_source(), control_swap_channel_in_bridge(), and stasis_app_exec().
int stasis_app_send_command | ( | struct stasis_app_control * | control, |
stasis_app_command_cb | command, | ||
void * | data, | ||
command_data_destructor_fn | data_destructor | ||
) |
Invokes a command on a control's channel.
control | Control object for the channel to send the command to. |
command | Command function to execute. |
data | Optional data to pass along with the control function. |
data_destructor | Optional function which will be called on the data in either the event of command completion or failure to schedule or complete the command |
Definition at line 920 of file control.c.
Referenced by ast_ari_bridges_set_video_source(), and stasis_app_control_answer().
int stasis_app_send_command_async | ( | struct stasis_app_control * | control, |
stasis_app_command_cb | command, | ||
void * | data, | ||
command_data_destructor_fn | data_destructor | ||
) |
Asynchronous version of stasis_app_send_command().
control | Control object for the channel to send the command to. |
command | Command function to execute. |
data | Optional data to pass along with the control function. |
data_destructor | Optional function which will be called on the data in either the event of command completion or failure to schedule or complete the command |
Definition at line 926 of file control.c.
References ao2_ref, and stasis_app_control::is_done.
Referenced by bridge_timeout(), dial_bridge_after_cb(), stasis_app_control_add_role(), stasis_app_control_clear_roles(), stasis_app_control_continue(), stasis_app_control_dial(), stasis_app_control_dtmf(), stasis_app_control_hold(), stasis_app_control_moh_start(), stasis_app_control_moh_stop(), stasis_app_control_move(), stasis_app_control_mute(), stasis_app_control_play_uri(), stasis_app_control_record(), stasis_app_control_redirect(), stasis_app_control_ring(), stasis_app_control_ring_stop(), stasis_app_control_set_channel_var(), stasis_app_control_silence_start(), stasis_app_control_silence_stop(), stasis_app_control_unhold(), and stasis_app_control_unmute().
|
static |
Singleton dial bridge.
The dial bridge is a holding bridge used to hold all outbound dialed channels that are not in any "real" ARI-created bridge. The dial bridge is invisible, meaning that it does not show up in channel snapshots, AMI or ARI output, and no events get raised for it.
This is used to keep dialed channels confined to the bridging system and unify the threading model used for dialing outbound channels.
struct ast_datastore_info timeout_datastore |
Dial timeout datastore.
A datastore is used because a channel may change bridges during the course of a dial attempt. This may be because the channel changes from the dial bridge to a standard bridge, or it may move between standard bridges. In order to keep the dial timeout, we need to keep the timeout information local to the channel. That is what this datastore is for