40 #include "asterisk/stasis_channels.h"
45 #include "asterisk/max_forwards.h"
55 if (!strcmp(reason,
"normal")) {
56 return AST_CAUSE_NORMAL;
57 }
else if (!strcmp(reason,
"busy")) {
58 return AST_CAUSE_BUSY;
59 }
else if (!strcmp(reason,
"congestion")) {
60 return AST_CAUSE_CONGESTION;
61 }
else if (!strcmp(reason,
"no_answer")) {
62 return AST_CAUSE_NOANSWER;
63 }
else if (!strcmp(reason,
"timeout")) {
64 return AST_CAUSE_NO_USER_RESPONSE;
65 }
else if (!strcmp(reason,
"rejected")) {
66 return AST_CAUSE_CALL_REJECTED;
67 }
else if (!strcmp(reason,
"unallocated")) {
68 return AST_CAUSE_UNALLOCATED;
69 }
else if (!strcmp(reason,
"normal_unspecified")) {
70 return AST_CAUSE_NORMAL_UNSPECIFIED;
71 }
else if (!strcmp(reason,
"number_incomplete")) {
72 return AST_CAUSE_INVALID_NUMBER_FORMAT;
73 }
else if (!strcmp(reason,
"codec_mismatch")) {
74 return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
75 }
else if (!strcmp(reason,
"interworking")) {
76 return AST_CAUSE_INTERWORKING;
77 }
else if (!strcmp(reason,
"failure")) {
78 return AST_CAUSE_FAILURE;
79 }
else if(!strcmp(reason,
"answered_elsewhere")) {
80 return AST_CAUSE_ANSWERED_ELSEWHERE;
133 "Channel in invalid state");
154 const char *channel_id)
158 ast_assert(response != NULL);
161 if (control == NULL) {
167 "Channel not found");
172 "Channel not in Stasis application");
191 ast_assert(response != NULL);
194 if (control == NULL) {
208 if (ast_strlen_zero(args->
context)) {
209 context = snapshot->dialplan->context;
216 if (!ast_strlen_zero(args->
label)) {
219 if (sscanf(args->
label,
"%30d", &ipri) != 1) {
222 ast_log(AST_LOG_ERROR,
"Requested label: %s can not be found in context: %s\n", args->
label, context);
227 ast_debug(3,
"Numeric value provided for label, jumping to that priority\n");
231 ast_log(AST_LOG_ERROR,
"Invalid priority label '%s' specified for extension %s in context: %s\n",
232 args->
label, exten, context);
240 }
else if (ast_strlen_zero(args->
context) && ast_strlen_zero(args->
extension)) {
242 ipri = snapshot->dialplan->priority + 1;
269 "Failed to switch Stasis applications");
295 if (ast_strlen_zero(args->
endpoint)) {
297 "Required parameter 'endpoint' not provided.");
302 if (!(resource = strchr(tech,
'/')) || !(tech_len = resource - tech)) {
304 "Endpoint parameter '%s' does not contain tech/resource", args->
endpoint);
309 if (ast_strlen_zero(resource)) {
311 "No resource provided in endpoint parameter '%s'", args->
endpoint);
316 if (!chan_snapshot) {
318 "Unable to find channel snapshot for '%s'", args->
channel_id);
322 if (strncasecmp(chan_snapshot->base->type, tech, tech_len)) {
324 "Endpoint technology '%s' does not match channel technology '%s'",
325 tech, chan_snapshot->base->type);
331 "Failed to redirect channel");
345 if (control == NULL) {
355 response, 500,
"Internal Server Error",
356 "Failed to answer channel");
370 if (control == NULL) {
390 if (control == NULL) {
408 unsigned int direction = 0;
412 if (control == NULL) {
422 response, 400,
"Bad Request",
423 "Direction is required");
428 direction = AST_MUTE_DIRECTION_READ;
429 }
else if (!strcmp(args->
direction,
"out")) {
430 direction = AST_MUTE_DIRECTION_WRITE;
431 }
else if (!strcmp(args->
direction,
"both")) {
432 direction = AST_MUTE_DIRECTION_READ | AST_MUTE_DIRECTION_WRITE;
435 response, 400,
"Bad Request",
436 "Invalid direction specified");
450 unsigned int direction = 0;
454 if (control == NULL) {
464 response, 400,
"Bad Request",
465 "Direction is required");
470 direction = AST_MUTE_DIRECTION_READ;
471 }
else if (!strcmp(args->
direction,
"out")) {
472 direction = AST_MUTE_DIRECTION_WRITE;
473 }
else if (!strcmp(args->
direction,
"both")) {
474 direction = AST_MUTE_DIRECTION_READ | AST_MUTE_DIRECTION_WRITE;
477 response, 400,
"Bad Request",
478 "Invalid direction specified");
494 if (control == NULL) {
502 if (ast_strlen_zero(args->
dtmf)) {
504 response, 400,
"Bad Request",
521 if (control == NULL) {
542 if (control == NULL) {
563 if (control == NULL) {
583 if (control == NULL) {
603 if (control == NULL) {
623 if (control == NULL) {
636 static void ari_channels_handle_play(
637 const char *args_channel_id,
638 const char **args_media,
639 size_t args_media_count,
640 const char *args_lang,
643 const char *args_playback_id,
649 RAII_VAR(
char *, playback_url, NULL, ast_free);
651 const char *language;
653 ast_assert(response != NULL);
656 if (control == NULL) {
668 response, 404,
"Not Found",
669 "Channel not found");
673 if (args_skipms < 0) {
675 response, 400,
"Bad Request",
676 "skipms cannot be negative");
680 if (args_offsetms < 0) {
682 response, 400,
"Bad Request",
683 "offsetms cannot be negative");
687 language =
S_OR(args_lang, snapshot->base->language);
693 response, 500,
"Internal Server Error",
694 "Failed to queue media for playback");
702 response, 500,
"Internal Server Error",
710 response, 500,
"Internal Server Error",
722 ari_channels_handle_play(
737 ari_channels_handle_play(
754 RAII_VAR(
char *, recording_url, NULL, ast_free);
758 RAII_VAR(
char *, uri_encoded_name, NULL, ast_free);
759 size_t uri_name_maxlen;
761 ast_assert(response != NULL);
765 response, 400,
"Bad Request",
766 "max_duration_seconds cannot be negative");
772 response, 400,
"Bad Request",
773 "max_silence_seconds cannot be negative");
778 if (control == NULL) {
784 if (options == NULL) {
786 response, 500,
"Internal Server Error",
792 options->terminate_on =
796 options->beep = args->
beep;
798 if (options->terminate_on == STASIS_APP_RECORDING_TERMINATE_INVALID) {
800 response, 400,
"Bad Request",
801 "terminateOn invalid");
807 response, 400,
"Bad Request",
814 response, 422,
"Unprocessable Entity",
815 "specified format is unknown on this system");
820 if (recording == NULL) {
827 response, 500,
"Internal Server Error",
828 "Error parsing request");
832 "Recording '%s' already exists and can not be overwritten",
837 response, 500,
"Internal Server Error",
842 response, 400,
"Bad Request",
843 "Recording name invalid");
847 "Unrecognized recording error: %s\n",
850 response, 500,
"Internal Server Error",
851 "Internal Server Error");
857 uri_name_maxlen = strlen(args->
name) * 3;
858 uri_encoded_name =
ast_malloc(uri_name_maxlen);
859 if (!uri_encoded_name) {
861 response, 500,
"Internal Server Error",
869 uri_encoded_name) == -1) {
870 recording_url = NULL;
872 response, 500,
"Internal Server Error",
880 response, 500,
"Internal Server Error",
897 response, 404,
"Not Found",
898 "Channel not found");
917 response, 404,
"Not Found",
918 "Channel not found");
924 "The reason and reason_code can't both be specified");
930 if (sscanf(args->
reason_code,
"%30d", &cause) != 1) {
932 response, 400,
"Invalid Reason Code",
933 "Invalid reason for hangup reason code provided");
936 }
else if (!ast_strlen_zero(args->
reason)) {
941 response, 400,
"Invalid Reason",
942 "Invalid reason for hangup reason provided");
947 cause = AST_CAUSE_NORMAL;
950 ast_channel_hangupcause_set(chan, cause);
966 snapshots = ast_channel_cache_all();
975 while ((obj = ao2_iterator_next(&i))) {
1024 if (!ast_strlen_zero(origination->
appdata)) {
1028 ast_verb(4,
"Launching Stasis(%s) on %s\n", origination->
appdata,
1032 ast_log(LOG_WARNING,
"No such application 'Stasis'\n");
1037 if (!ast_strlen_zero(origination->
context)) {
1038 ast_channel_context_set(answered, origination->
context);
1041 if (!ast_strlen_zero(origination->
exten)) {
1042 ast_channel_exten_set(answered, origination->
exten);
1046 ast_channel_priority_set(answered, origination->
priority);
1050 ast_log(LOG_ERROR,
"Failed to start PBX on %s\n", ast_channel_name(answered));
1059 ast_free(origination);
1063 static struct ast_channel *ari_channels_handle_originate_with_id(
const char *args_endpoint,
1064 const char *args_extension,
1065 const char *args_context,
1067 const char *args_label,
1068 const char *args_app,
1069 const char *args_app_args,
1070 const char *args_caller_id,
1073 const char *args_channel_id,
1074 const char *args_other_channel_id,
1075 const char *args_originator,
1076 const char *args_formats,
1080 char *dialdevice = NULL;
1082 char *caller_id = NULL;
1083 char *cid_num = NULL;
1084 char *cid_name = NULL;
1090 .uniqueid = args_channel_id,
1091 .uniqueid2 = args_other_channel_id,
1104 if (ast_strlen_zero(args_endpoint)) {
1106 "Endpoint must be specified");
1110 if (!ast_strlen_zero(args_originator) && !ast_strlen_zero(args_formats)) {
1112 "Originator and formats can't both be specified");
1117 if ((stuff = strchr(dialtech,
'/'))) {
1122 if (ast_strlen_zero(dialtech) || ast_strlen_zero(dialdevice)) {
1124 "Invalid endpoint specified");
1128 if (!ast_strlen_zero(args_app)) {
1137 if (!ast_strlen_zero(args_app_args)) {
1148 }
else if (!ast_strlen_zero(args_extension)) {
1149 origination =
ast_calloc(1,
sizeof(*origination) + 1);
1158 if (!ast_strlen_zero(args_label)) {
1161 if (sscanf(args_label,
"%30d", &ipri) != 1) {
1165 ast_log(AST_LOG_ERROR,
"Requested label: %s can not be found in context: %s\n", args_label, args_context);
1170 ast_debug(3,
"Numeric value provided for label, jumping to that priority\n");
1174 ast_log(AST_LOG_ERROR,
"Invalid priority label '%s' specified for extension %s in context: %s\n",
1175 args_label, args_extension, args_context);
1184 origination->
priority = args_priority ? args_priority : 1;
1187 origination->
appdata[0] =
'\0';
1190 "Application or extension must be specified");
1197 ast_free(origination);
1205 ast_free(origination);
1209 if (args_timeout > 0) {
1211 }
else if (args_timeout == -1) {
1217 if (!ast_strlen_zero(args_caller_id)) {
1226 if (!ast_strlen_zero(args_originator)) {
1230 response, 400,
"Bad Request",
1231 "Provided originator channel was not found");
1233 ast_free(origination);
1238 if (!ast_strlen_zero(args_formats)) {
1245 ast_free(origination);
1250 while ((format_name =
ast_strip(strsep(&formats_copy,
",")))) {
1256 response, 400,
"Bad Request",
1257 "Provided format (%s) was not found", format_name);
1262 ast_free(origination);
1275 "Channel with given unique ID already exists");
1280 ast_free(origination);
1286 ao2_cleanup(format_cap);
1292 ast_free(origination);
1296 if (!ast_strlen_zero(cid_num) || !ast_strlen_zero(cid_name)) {
1310 if (!ast_strlen_zero(cid_num)) {
1311 connected.id.number.valid = 1;
1312 connected.id.number.str = (
char *) cid_num;
1313 connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
1315 if (!ast_strlen_zero(cid_name)) {
1316 connected.id.name.valid = 1;
1317 connected.id.name.str = (
char *) cid_name;
1318 connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
1323 ast_channel_lock(chan);
1329 if (!ast_strlen_zero(args_app)) {
1343 ast_channel_unlock(chan);
1353 ast_free(origination);
1383 "Only string values in the 'variables' object allowed");
1389 ast_log(AST_LOG_ERROR,
"Unable to convert 'variables' in JSON body to channel variables\n");
1408 && json_to_ast_variables(response, json_variables, &variables)) {
1413 chan = ari_channels_handle_originate_with_id(
1447 && json_to_ast_variables(response, json_variables, &variables)) {
1452 chan = ari_channels_handle_originate_with_id(
1481 ast_assert(response != NULL);
1488 if (ast_strlen_zero(args->
variable)) {
1490 response, 400,
"Bad Request",
1491 "Variable name is required");
1497 response, 400,
"Bad Request",
1498 "Channel ID is required");
1505 response, 404,
"Channel Not Found",
1506 "Provided channel was not found");
1520 response, 500,
"Error With Function",
1521 "Unable to read provided function");
1527 response, 404,
"Variable Not Found",
1528 "Provided variable was not found");
1547 ast_assert(response != NULL);
1549 if (ast_strlen_zero(args->
variable)) {
1551 response, 400,
"Bad Request",
1552 "Variable name is required");
1557 if (control == NULL) {
1564 response, 400,
"Bad Request",
1565 "Failed to execute function");
1572 static void ari_channels_handle_snoop_channel(
1573 const char *args_channel_id,
1574 const char *args_spy,
1575 const char *args_whisper,
1576 const char *args_app,
1577 const char *args_app_args,
1578 const char *args_snoop_id,
1586 ast_assert(response != NULL);
1588 if (ast_strlen_zero(args_spy) || !strcmp(args_spy,
"none")) {
1590 }
else if (!strcmp(args_spy,
"both")) {
1592 }
else if (!strcmp(args_spy,
"out")) {
1594 }
else if (!strcmp(args_spy,
"in")) {
1598 response, 400,
"Bad Request",
1599 "Invalid direction specified for spy");
1603 if (ast_strlen_zero(args_whisper) || !strcmp(args_whisper,
"none")) {
1605 }
else if (!strcmp(args_whisper,
"both")) {
1607 }
else if (!strcmp(args_whisper,
"out")) {
1609 }
else if (!strcmp(args_whisper,
"in")) {
1613 response, 400,
"Bad Request",
1614 "Invalid direction specified for whisper");
1620 response, 400,
"Bad Request",
1621 "Direction must be specified for at least spy or whisper");
1623 }
else if (ast_strlen_zero(args_app)) {
1625 response, 400,
"Bad Request",
1626 "Application name is required");
1633 response, 404,
"Channel Not Found",
1634 "Provided channel was not found");
1640 if (snoop == NULL) {
1642 response, 500,
"Internal error",
1643 "Snoop channel could not be created");
1655 ari_channels_handle_snoop_channel(
1669 ari_channels_handle_snoop_channel(
1686 ast_free(chan_data->stasis_stuff);
1688 ast_free(chan_data);
1705 ast_log(LOG_ERROR,
"Stasis dialplan application is not registered");
1706 chan_data_destroy(chan_data);
1712 chan_data_destroy(chan_data);
1718 .
type =
"ARI Dialstring",
1736 datastore = ast_datastore_alloc(&dialstring_info, NULL);
1742 if (!datastore->
data) {
1747 ast_channel_lock(chan);
1749 ast_channel_unlock(chan);
1753 ast_channel_unlock(chan);
1775 return datastore->
data;
1788 char *dialdevice = NULL;
1801 && json_to_ast_variables(response, json_variables, &variables)) {
1811 "Originator and formats can't both be specified");
1815 if (ast_strlen_zero(args->
endpoint)) {
1817 "Endpoint must be specified");
1821 chan_data =
ast_calloc(1,
sizeof(*chan_data));
1828 if (!chan_data->stasis_stuff) {
1830 chan_data_destroy(chan_data);
1835 if (!ast_strlen_zero(args->
app_args)) {
1840 if ((stuff = strchr(dialtech,
'/'))) {
1845 if (ast_strlen_zero(dialtech) || ast_strlen_zero(dialdevice)) {
1847 "Invalid endpoint specified");
1848 chan_data_destroy(chan_data);
1854 request_cap =
ao2_bump(ast_channel_nativeformats(originator));
1855 if (!ast_strlen_zero(args->
app)) {
1858 }
else if (!ast_strlen_zero(args->
formats)) {
1864 chan_data_destroy(chan_data);
1868 while ((format_name =
ast_strip(strsep(&formats_copy,
",")))) {
1874 response, 400,
"Bad Request",
1875 "Provided format (%s) was not found", format_name);
1881 chan_data_destroy(chan_data);
1889 chan_data_destroy(chan_data);
1896 chan_data->chan =
ast_request(dialtech, request_cap, &assignedids, originator, dialdevice, &cause);
1897 ao2_cleanup(request_cap);
1899 if (!chan_data->chan) {
1902 "Channel with given unique ID already exists");
1907 chan_data_destroy(chan_data);
1911 if (!ast_strlen_zero(args->
app)) {
1923 chan_data_destroy(chan_data);
1931 chan_data_destroy(chan_data);
1949 if (control == NULL) {
1959 "Callee not found");
1966 "Channel is not in the 'Down' state");
1976 ast_channel_lock(callee);
1981 ast_channel_unlock(callee);
1983 ast_channel_unlock(caller);
1986 "Dialing a channel not created by ARI");
1998 ast_max_forwards_decrement(callee);
2007 ast_channel_language_set(callee, ast_channel_language(caller));
2009 if (ast_strlen_zero(ast_channel_musicclass(callee)))
2010 ast_channel_musicclass_set(callee, ast_channel_musicclass(caller));
2012 ast_channel_adsicpe_set(callee, ast_channel_adsicpe(caller));
2013 ast_channel_transfercapability_set(callee, ast_channel_transfercapability(caller));
2014 ast_channel_unlock(caller);
2018 ast_channel_unlock(callee);
2041 "Channel not found");
2045 ast_channel_lock(chan);
2048 ast_channel_unlock(chan);
2050 "Channel's tech not found");
2056 ast_channel_unlock(chan);
2058 "Unsupported channel type");
2064 ast_channel_unlock(chan);
2066 "RTP info not found");
2072 ast_channel_unlock(chan);
2074 "Statistics not found");
2078 ast_channel_unlock(chan);
2098 chan = ari_channels_handle_originate_with_id(
2122 ast_channel_lock(chan);
2123 vars = ast_channel_varshead(chan);
2127 ast_channel_unlock(chan);
2136 size_t endpoint_len;
2141 if (ast_strlen_zero(args->
data)) {
2146 endpoint_len = strlen(
"AudioSocket/") + strlen(args->
external_host) + 1 + strlen(args->
data) + 1;
2149 snprintf(endpoint, endpoint_len,
"AudioSocket/%s/%s", args->
external_host, args->
data);
2151 chan = ari_channels_handle_originate_with_id(
2173 ast_channel_lock(chan);
2174 vars = ast_channel_varshead(chan);
2178 ast_channel_unlock(chan);
2189 char *external_host;
2193 ast_assert(response != NULL);
2202 && json_to_ast_variables(response, json_variables, &variables)) {
2207 if (ast_strlen_zero(args->
app)) {
2223 if (ast_strlen_zero(args->
format)) {
2242 if (external_media_rtp_udp(args, variables, response)) {
2244 response, 500,
"Internal Server Error",
2245 "An internal error prevented this request from being handled");
2247 }
else if (strcasecmp(args->
encapsulation,
"audiosocket") == 0 && strcasecmp(args->
transport,
"tcp") == 0) {
2248 external_media_audiosocket_tcp(args, variables, response);
2251 response, 501,
"Not Implemented",
2252 "The encapsulation and/or transport is not supported");
int ast_ari_channels_external_media_parse_body(struct ast_json *body, struct ast_ari_channels_external_media_args *args)
Body parsing function for /channels/externalMedia.
void ast_ari_channels_ring_stop(struct ast_variable *headers, struct ast_ari_channels_ring_stop_args *args, struct ast_ari_response *response)
Stop ringing indication on a channel if locally generated.
Stasis Application Recording API. See StasisApplication API" for detailed documentation.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Main Channel structure associated with a channel.
Local proxy channel special access.
stasis_app_snoop_direction
Directions for audio stream flow.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
Structure used for origination.
void ast_ari_channels_external_media(struct ast_variable *headers, struct ast_ari_channels_external_media_args *args, struct ast_ari_response *response)
Start an External Media session.
Asterisk main include file. File version handling, generic pbx functions.
void ast_ari_channels_move(struct ast_variable *headers, struct ast_ari_channels_move_args *args, struct ast_ari_response *response)
Move the channel from one Stasis application to another.
void * ast_dial_get_user_data(struct ast_dial *dial)
Return the user data on a dial structure.
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.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Main dialing structure. Contains global options, channels being dialed, and more! ...
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
#define ast_channel_unref(c)
Decrease channel reference count.
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation...
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...
struct ast_json * variables
void ast_ari_channels_list(struct ast_variable *headers, struct ast_ari_channels_list_args *args, struct ast_ari_response *response)
List all active channels in Asterisk.
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Audio stream in from the channel.
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
void ast_ari_response_created(struct ast_ari_response *response, const char *url, struct ast_json *message)
Fill in a Created (201) ast_ari_response.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_ari_channels_originate(struct ast_variable *headers, struct ast_ari_channels_originate_args *args, struct ast_ari_response *response)
Create a new channel (originate).
const char * other_channel_id
int ast_ari_channels_create_parse_body(struct ast_json *body, struct ast_ari_channels_create_args *args)
Body parsing function for /channels/create.
Structure for variables, used for configurations and for channel variables.
char * ast_uri_encode(const char *string, char *outbuf, int buflen, struct ast_flags spec)
Turn text string to URI-encoded XX version.
void ast_ari_channels_redirect(struct ast_variable *headers, struct ast_ari_channels_redirect_args *args, struct ast_ari_response *response)
Redirect the channel to a different location.
Structure representing a snapshot of channel state.
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
void ast_ari_channels_get(struct ast_variable *headers, struct ast_ari_channels_get_args *args, struct ast_ari_response *response)
Channel details.
int stasis_app_control_ring_stop(struct stasis_app_control *control)
Stop locally generated ringing on the channel associated with this control.
Structure to pass both assignedid values to channel drivers.
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.
void stasis_app_control_hold(struct stasis_app_control *control)
Place the channel associated with the control on hold.
void stasis_app_control_silence_stop(struct stasis_app_control *control)
Stop playing silence to a channel.
Structure for a data store type.
void ast_ari_channels_play_with_id(struct ast_variable *headers, struct ast_ari_channels_play_with_id_args *args, struct ast_ari_response *response)
Start playback of media and specify the playbackId.
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.
ast_channel_state
ast_channel states
struct ast_json * stasis_app_playback_to_json(const struct stasis_app_playback *playback)
Convert a playback to its JSON representation.
int priority
Dialplan priority.
static void * ari_channel_thread(void *data)
Thread that owns stasis-created channel.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
const char * other_channel_id
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
void ast_ari_channels_record(struct ast_variable *headers, struct ast_ari_channels_record_args *args, struct ast_ari_response *response)
Start a recording.
Generated file - declares stubs to be implemented in res/ari/resource_channels.c. ...
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
static int convert_reason_to_hangup_code(const char *reason)
Return the corresponded hangup code of the given reason.
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.
Audio stream to AND from the channel.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
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.
char stasis_app_recording_termination_parse(const char *str)
Parse a string into the recording termination enum.
struct ast_json * variables
void ast_ari_channels_hold(struct ast_variable *headers, struct ast_ari_channels_hold_args *args, struct ast_ari_response *response)
Hold a channel.
int ast_is_shrinkable_phonenumber(const char *exten)
Check if a string consists only of digits and + # ( ) - . (meaning it can be cleaned with ast_shrink_...
void ast_free_ptr(void *ptr)
free() wrapper
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
void ast_ari_channels_get_channel_var(struct ast_variable *headers, struct ast_ari_channels_get_channel_var_args *args, struct ast_ari_response *response)
Get the value of a channel variable or function.
Structure containing callbacks for Stasis message sanitization.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
void ast_ari_channels_rtpstatistics(struct ast_variable *headers, struct ast_ari_channels_rtpstatistics_args *args, struct ast_ari_response *response)
RTP stats on a channel.
struct ast_json * ast_rtp_instance_get_stats_all_json(struct ast_rtp_instance *instance)
Retrieve statistics about an RTP instance in json format.
static char * restore_dialstring(struct ast_channel *chan)
Retrieve the dialstring from the channel datastore.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
struct ast_channel * ast_local_get_peer(struct ast_channel *ast)
Get the other local channel in the pair.
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_dial_set_user_data(struct ast_dial *dial, void *user_data)
Set user data on a dial structure.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Conversion failed because invalid value type supplied.
struct ast_json * ast_json_channel_vars(struct varshead *channelvars)
Construct a JSON object from a ast_var_t list.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
void ast_ari_channels_unmute(struct ast_variable *headers, struct ast_ari_channels_unmute_args *args, struct ast_ari_response *response)
Unmute a channel.
const char * stasis_app_playback_get_id(struct stasis_app_playback *playback)
Gets the unique id of a playback object.
struct ast_json * stasis_app_recording_to_json(const struct stasis_app_recording *recording)
Construct a JSON model of a recording.
Configuration File Parser.
char exten[AST_MAX_EXTENSION]
Dialplan extension.
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
const char * other_channel_id
int ast_ari_channels_originate_parse_body(struct ast_json *body, struct ast_ari_channels_originate_args *args)
Body parsing function for /channels.
void ast_ari_channels_create(struct ast_variable *headers, struct ast_ari_channels_create_args *args, struct ast_ari_response *response)
Create channel.
ast_dial_result
List of return codes for dial run API calls.
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
enum ast_rtp_glue_result(* get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying audio.
static int save_dialstring(struct ast_channel *chan, const char *dialstring)
Save dialstring onto a channel datastore.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_ari_channels_answer(struct ast_variable *headers, struct ast_ari_channels_answer_args *args, struct ast_ari_response *response)
Answer a channel.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define AST_MAX_EXTENSION
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
int stasis_app_control_dial(struct stasis_app_control *control, const char *dialstring, unsigned int timeout)
Dial a channel.
Audio stream out to the channel.
void ast_ari_channels_stop_silence(struct ast_variable *headers, struct ast_ari_channels_stop_silence_args *args, struct ast_ari_response *response)
Stop playing silence to a channel.
#define ast_malloc(len)
A wrapper for malloc()
void ast_ari_channels_continue_in_dialplan(struct ast_variable *headers, struct ast_ari_channels_continue_in_dialplan_args *args, struct ast_ari_response *response)
Exit application; continue execution in the dialplan.
#define ast_debug(level,...)
Log a DEBUG message.
void ast_ari_channels_snoop_channel_with_id(struct ast_variable *headers, struct ast_ari_channels_snoop_channel_with_id_args *args, struct ast_ari_response *response)
Start snooping.
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Structure to describe a channel "technology", ie a channel driver See for examples: ...
char context[AST_MAX_CONTEXT]
Dialplan context.
Core PBX routines and definitions.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
ast_frame_type
Frame types.
void ast_ari_channels_start_silence(struct ast_variable *headers, struct ast_ari_channels_start_silence_args *args, struct ast_ari_response *response)
Play silence to a channel.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
int ast_ari_channels_originate_with_id_parse_body(struct ast_json *body, struct ast_ari_channels_originate_with_id_args *args)
Body parsing function for /channels/{channelId}.
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
struct ast_json * variables
enum ast_record_if_exists stasis_app_recording_if_exists_parse(const char *str)
Parse a string into the if_exists enum.
Support for dynamic strings.
int stasis_app_control_ring(struct stasis_app_control *control)
Indicate ringing to the channel associated with this control.
void ast_ari_channels_send_dtmf(struct ast_variable *headers, struct ast_ari_channels_send_dtmf_args *args, struct ast_ari_response *response)
Send provided DTMF to a given channel.
int stasis_app_control_redirect(struct stasis_app_control *control, const char *endpoint)
Redirect a channel in res_stasis to a particular endpoint.
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
Connected Line/Party information.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
struct ast_channel_snapshot * stasis_app_control_get_snapshot(const struct stasis_app_control *control)
Returns the most recent snapshot for the associated channel.
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
static int channel_state_invalid(struct stasis_app_control *control, struct ast_ari_response *response)
Ensure channel is in a state that allows operation to be performed.
char appdata[0]
Application data to pass to Stasis application.
enum ast_json_to_ast_vars_code ast_json_to_ast_variables(struct ast_json *json_variables, struct ast_variable **variables)
Convert a ast_json list of key/value pair tuples into a ast_variable list.
void ast_ari_channels_set_channel_var(struct ast_variable *headers, struct ast_ari_channels_set_channel_var_args *args, struct ast_ari_response *response)
Set the value of a channel variable or function.
Conversion failed because of allocation failure. (Out Of Memory)
void stasis_app_control_unhold(struct stasis_app_control *control)
Remove the channel associated with the control from hold.
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
#define ast_calloc(num, len)
A wrapper for calloc()
struct ast_dial * ast_dial_create(void)
New dialing structure.
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
struct ast_channel * ast_dial_get_channel(struct ast_dial *dial, int num)
Get the dialing channel, if prerun has been executed.
void ast_ari_channels_originate_with_id(struct ast_variable *headers, struct ast_ari_channels_originate_with_id_args *args, struct ast_ari_response *response)
Create a new channel (originate with id).
enum stasis_app_subscribe_res stasis_app_subscribe_channel(const char *app_name, struct ast_channel *chan)
Directly subscribe an application to a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
struct stasis_app_recording_options * stasis_app_recording_options_create(const char *name, const char *format)
Allocate a recording options object.
void ast_ari_response_no_content(struct ast_ari_response *response)
Fill in a No Content (204) ast_ari_response.
enum ast_channel_state state
struct ast_format * ast_get_format_for_file_ext(const char *file_ext)
Get the ast_format associated with the given file extension.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
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_json * message
void ast_ari_channels_hangup(struct ast_variable *headers, struct ast_ari_channels_hangup_args *args, struct ast_ari_response *response)
Delete (i.e. hangup) a channel.
void ast_ari_channels_play(struct ast_variable *headers, struct ast_ari_channels_play_args *args, struct ast_ari_response *response)
Start playback of media.
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.
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
void ast_ari_channels_mute(struct ast_variable *headers, struct ast_ari_channels_mute_args *args, struct ast_ari_response *response)
Mute a channel.
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
int transit_network_select
Transit Network Select.
#define AST_MAX_PUBLIC_UNIQUEID
static struct stasis_app_control * find_control(struct ast_ari_response *response, const char *channel_id)
Finds the control object for a channel, filling the response with an error, if appropriate.
Stasis Application Playback API. See StasisApplication API" for detailed documentation.
const char * ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var)
void ast_ari_channels_start_moh(struct ast_variable *headers, struct ast_ari_channels_start_moh_args *args, struct ast_ari_response *response)
Play music on hold to a channel.
#define ast_channel_ref(c)
Increase channel reference count.
static void * ari_originate_dial(void *data)
Thread which dials and executes upon answer.
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...
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
ast_app: A registered application
Stasis Application Snoop API. See StasisApplication API" for detailed documentation.
struct stasis_app_playback * stasis_app_control_play_uri(struct stasis_app_control *control, const char **media, size_t media_count, const char *language, const char *target_id, enum stasis_app_playback_target_type target_type, int skipms, long offsetms, const char *id)
Play a file to the control's channel.
int stasis_app_control_answer(struct stasis_app_control *control)
Answer the channel associated with this control.
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
Internal Asterisk hangup causes.
struct ast_channel * stasis_app_control_snoop(struct ast_channel *chan, enum stasis_app_snoop_direction spy, enum stasis_app_snoop_direction whisper, const char *app, const char *app_args, const char *snoop_id)
Create a snoop on the provided channel.
Abstract JSON element (object, array, string, int, ...).
void stasis_app_control_silence_start(struct stasis_app_control *control)
Start playing silence to a channel.
void ast_ari_channels_snoop_channel(struct ast_variable *headers, struct ast_ari_channels_snoop_channel_args *args, struct ast_ari_response *response)
Start snooping.
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.
Stasis Application API. See Stasis Application API for detailed documentation.
void ast_ari_channels_stop_moh(struct ast_variable *headers, struct ast_ari_channels_stop_moh_args *args, struct ast_ari_response *response)
Stop playing music on hold to a channel.
enum ast_channel_error ast_channel_errno(void)
Get error code for latest channel operation.
void ast_ari_channels_ring(struct ast_variable *headers, struct ast_ari_channels_ring_args *args, struct ast_ari_response *response)
Indicate ringing to a channel.
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_app_control_moh_stop(struct stasis_app_control *control)
Stop playing music on hold to a channel (does not affect hold status)
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
struct ast_app * pbx_findapp(const char *app)
Look up an application.
void ast_ari_channels_dial(struct ast_variable *headers, struct ast_ari_channels_dial_args *args, struct ast_ari_response *response)
Dial a created channel.
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Pluggable RTP Architecture.
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)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_channel_snapshot * snapshot
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
ast_json_to_ast_vars_code
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
void ast_ari_channels_unhold(struct ast_variable *headers, struct ast_ari_channels_unhold_args *args, struct ast_ari_response *response)
Remove a channel from hold.
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
struct stasis_app_recording * stasis_app_control_record(struct stasis_app_control *control, struct stasis_app_recording_options *options)
Record media from a channel.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
const char * terminate_on
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
int ast_dial_prerun(struct ast_dial *dial, struct ast_channel *chan, struct ast_format_cap *cap)
Request all appended channels, but do not dial.